Installation setup wizard for small yii2 project.

Hi All,

Greetings for the day !!!.

I have created small yii2 application MyLibrary.

having 3 modules like Books,Authors & Publishers.

I need following for my preoject.

As like many projects.we will extract zip file into server directory.

Now when we will access it through web browser,as it is first time ,[b]It will display setup wizard with steps.

like PHP version check,DB details & sample data.[/b]

How can I create same things for my small project. So that I can upload my project on to github.

Any inputs will be highly appreciated.

Thanks,

Vishwas

When I first read your question, I was thinking "Why not just use Composer and push it to your server?"… It even works on traditional servers (normal servers, cpanel, etc) not just the new fangled "cloud" hosts.

Then I read it again, and I think I see what your wanting. You are wanting to do something similar to Wordpress. Where users download your script and upload it to their server. Then go to their site and are presented with an easy to use setup wizard.

I will just give some routes to take and things to think about… If you are creating something for the public, you should be able to code it yourself…

You will want to remove the database information from the config file, and it will be loaded either via variable or combined similar to how the main.php files are combined/merged in the advanced application.

You will want a simple check to run when a page is requested. I would NOT do a database check/call for this. You would need a config.php (named whatever you want) like Wordpress. Have a constant variable like ‘SCRIPT_INSTALLED’ defaulting to false. Check if the config.php file exists and desired values are present. If so, mark ‘SCRIPT_INSTALLED’ to true.

If SCRIPT_INSTALLED is false, redirect to your setup/install controller. So you would need to create a new Controller to handle your installation. Define rules to only allow access to this controller if ‘SCRIPT_INSTALLED’ is false. Your controller will have a form on it, custom code to check if the database connection was successful, etc. If everything is good, this will create the ‘config.php’ file for them. Create tables, etc, if necessary… Would probably keep a database version number stored in your db, so you script can detect upgrades, etc.

Merge config.php with main.php so Yii2 has the database values.

As Wade has suggested implicitly, a thing like "installation wizard" is a bit too expensive for our ordinary projects. If you are not writing a sophisticated CMS or something like Wordpress, I would recommend you to write a good documentation on the installation and the usage of your app instead.

If you google "yii2 wizard" you will find two basic extensions which you can use as a base to build your multistep install tool.

Have a look at opensource yii2 projects, that may also be helpful: