Symfony is a rich web application framework based on PHP. They describe symfony as a set of useable decoupled components. Because if you don’t need to use the complete framework you can use components from a framework in your application.

Or even base your own framework on Symfony. Laravel is based on Symfony and Drupal inherits many components from Symfony. In this article, we will be using composer to create a symfony application on CyberPanel.

Step 1: Install CyberPanel!

First, you need to get CyberPanel installed. CyberPanel is a web hosting control panel based on OpenLiteSpeed web server.

Step 2: Install Composer!

To install Composer you need php-cli. CyberPanel comes with PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1. We will use php-cli from PHP 7.1 because Symfony 4 requires php 7.1 and above. You can copy PHP 7.1 binary, so that it is available globally.

1

cp/usr/local/lsws/lsphp71/bin/php/usr/bin/

With this, you can use php-cli by just trying ‘php’. You can verify this using ‘php -v’.

1

php-v

You should get :

1

2

3

4

PHP7.1.12(cli)(built:Nov24201702:33:55)(NTS)

Copyright(c)1997-2017The PHP Group

Zend Engine v3.1.0,Copyright(c)1998-2017Zend Technologies

with Zend OPcache v7.1.12,Copyright(c)1999-2017,by Zend Technologies

That means you are ready to install composer. To install composer use these commands:

You can use composer project-wise, but for convenience, you can copy composer binary to a global location using:

1

cp composer.phar/usr/bin/composer

Now composer is also available globally and you can invoke it just using ‘composer’ command. With all this behind us, we are ready to create our first site and launch a Symfony application.

Step 3: Create Website!

To launch your Symfony application, you need to create a website in your CyberPanel.

From left menu click ‘Create Website’, enter all details and make sure to select ‘PHP 7.1’ because Symfony 4 requires PHP 7.1 and above.

Once the website is successfully created you can use composer to create a Symfony web application.

Step 4: Create Symfony Application

You need to have SSH access to use composer and create Symfony application, the home directory of every CyberPanel website looks like /home/example.com/public_html. Following this directory structure, you can now create your application.

1

2

cd/home/symfony.cyberpanel.net/public_html

composer create-project symfony/skeleton cyberpanel

These commands will create a Symfony application with appropriate directory structure, you can replace cyberpanel with the project name that you would like to give to your application.

Visit http://example.com/cyberpanel/public and you should see something like this:

This means you have successfully created Symfony application.

Step 5: Edit Rewrite Rules!

Like all frameworks, Symfony has its own rewrite engine which dispatches requests to different controllers depending on the path in URL, and there is only one front file named index.php which handles all requests and routes them accordingly. You need to specify rewrite rules so that all requests are dispatched to index.php

1

RewriteRule./cyberpanel/public/index.php[L]

cyberpanel here is the project name, you can replace it with the project name you used. Follow following guides to set up these rewrite rules: