Symfony installer

Let’s create a UI to install and configure our Symfony open-source projects.

I’m planing to release the forum application used by A Php7/MySQL/Redis project powered by Symfony 3.4. I’ve already try to release it with a open source version many times in the last years, but every attempt failed.

One of the difficulty, is to make installation easy for non IT people. You can’t ask them to use composer to bootstrap the project, even install composer or using command line. Mostly, the maximum you can require is to unzip a folder and move it to a FTP location.

For ages, a lot of CMS or Forum software have create UI to configure and install a project. I can remember the Xoops installer back in 2005.

Configuration of the database credentials, dataset creation or administrator user are for example very common steps.

I think this type of UI are “games changer” for an open-source project. This seriously help more users than a well documented installation process. And it encourage new welcomers to join the project, instead or restrict it to “composer” users.

I’ve look for this kind of UI for a Symfony project, and I couldn’t find one. Even very big project like Sylius doesn’t have this kind of UI.

So I decide to make my own Symfony project installer.

Very first idea was to have a distinct project that can be directly available via the browser. This project should use Symfony 4 and should be customizable to any Symfony project (or more).

So here we are:

How does it work ?

The project installer has to been incorporate in a Symfony project under a “installer” folder for example. It will generate from this path yaml files to a destination folder (that can be overwrite in a configuration file). You might use a symbolic link from your project /public/index.php to the installer/public/index.php file and replace it at the end of the process.

I really enjoy developing this project with Symfony 4! The Dependency Injection component became so powerfull with the lastest improvements.

Basically the project installer is a succession of steps doing or asking differents things to the user, forms in fact. Those steps must have a priority (aka stepNumber) to have logical process like creating the database before creating an admin users. Step must also have a function to check is they have been already done before hand over to next step, this will be the support method. And to finalize our step requirement, we will require a way to get the form (getForm), handle it (handle) and render information to have sophisticated view.

And so here’s the power of the DI Component. In a minimal configuration, all my steps are declared as service, tagged and injected in my StepSorter service:

The step sorter is ordering step depending their number and checking their current “support” method to return the current step.

So now let’s check the controller action with what’s already done:

Special trick is done to retrieve the template filename using the Step class.

And now ?

The project is available on Github. You can fork it, edit and create your own steps.

There’re many more thing to do like adding form’s validation, better UI, previous steps re-configuration or

Using the process component a step downloading and launching Composer could be done.