Using Composer create Symfony application on CyberPanel!

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.

You will need a fresh install of CentOS 7.

Replace IP Address with your vps/dedicated server IP Address. For more details visit installation.

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.

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

You should get :

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:

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.

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

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:

Setup Rewrite Rules on CyberPanel

Leave a Reply