Create a landing page in a few clicks

I wanna tell you how to build a landing page on Silex framework.
It’s really simple and will take just a few minutes from the start to adding template.
Fist of all we need to create a folder for our project and initialize composer in it (if composer is not installed follow this guide):

Then follow instructions, and when you will be asked a question about adding dependencies, answer “yes”. Add dependencies on silex:

Also you can add some useful modules for templating and setting config:

Or you can add composer.json into your project’s folder manually. My config looks like this:

Then run “composer install” command to prepare all vendors of the project.
I’ve also prepared such structure of folders:

Now we’re ready to write some php code. Let’s create ./bootstrap.php file, that will configure our silex application:

For the front requests we’ll create file with routings, which will extend the bootstrap. Put it to the ./web/app.php:

Then add general template to the ./web/views/index.html.twig

We can start it within nginx, apache or built-in php server from the project directory (only for php version >= 5.4.0):

You can see you landing page by the url http://localhost:8000/app.php

The application is ready!

Leave a Reply