
Composer Available on Shared Hosting Environment
Composer is a tool for dependencies management which enables you to easily download all the required packages/libraries your PHP project can use. The tool is dependent on the PHP service and from this point on will be available on all our Shared Hosting packages.
The main idea is for Composer to become the most used dependencies management tool the same as the Node’s npm and Ruby’s Bundler however for one of the most used backend programming languages – PHP.
How does Composer make Your Project a Fine-Tuned Orchestra?
The most common reference to Composer is an actual orchestra. Think of your web hosting account as one big orchestra and all of your PHP projects as different musicians. Every composer needs to show the tempo to all these musicians so they can all perform their best when a concert is underway.
What Composer actually do is that it installs for you packages/libraries defined by your project. If you have for example 20 projects in 20 different folders you can use Composer in each folder to download and install the requirements of your projects with a few simple commands which you will find below.
Usage
You probably wonder what you will need this tool for. With the increasing demand from Backend PHP Developers for an easy dependencies management tool, the requirements for the Shared Hosting environment are also growing to a point where the hosting companies cannot afford to miss this feature.
First and most important you will need SSH access to your account. If you are not quite sure how to get that, please submit a support ticket and our technical support team will gladly provide you with such.
Secondly, you will need to have a good knowledge of the file system of Linux and most importantly to where your projects are stored.
Finally, in order to use composer, you will need to type the composer command.
$ composer
Pretty easy isn’t it?
Example
Let’s cut down the theory and see how Composer actually performs when it comes to the installation process for one of the most used PHP Frameworks – Symfony 2.
First, let’s begin with the creation of our project:
$ composer create-project Symfony/framework-standard-edition test_project
Please replace “test_project” with the actual name of your project and keep in mind that the process will create a folder with the same name.
After a brief installation log for the dependencies required by Symfony 2 you will be prompted with the question if you would like to install the Acme Demo bundle which is the default one for Symfony:
Generating autoload files
Would you like to install Acme demo bundle? [y/N]
Next, you will be asked for the database details your Symfony application should be using. If you are not familiar with the cPanel service and you have not a glimpse of how to create a database/username and a password, we got your back as we have a detailed tutorial on How to create a cPanel database.
Creating the "app/config/parameters.
yml" file
Some parameters are missing. Please provide them.
database_driver (pdo_mysql):
Here you should press Enter as this is the default database driver.
database_host (127.0.0.1):
Enter again as this is the address for the database server available for your hosting account with us.
database_port (null): 3306
The default port for the MySQL service – 3306 on all our packages.
database_name (symfony): database_name
database_user (root): database_user
database_password (null): password
Please replace the database_name
with the actual database name you have created earlier, the database_user
with the user having privileges to operate with the created database and finally the “password” with the actual password for that user.
Next, you will be prompted with the settings for the SMTP protocol but you should set that up only if you will need to use it.
Finally, Composer will ask you for the “Locale
” that should be used by your application and of course the “secret
” token which will be used for encoding.
locale (en):
secret (ThisTokenIsNotSoSecretChangeIt):
After a few seconds you will get a message that the assets are installed for the used bundles and with that, the installation is finished.
Now if you access yourdomain.com/test_project/web/app_dev.php (where yourdomain.com should be replaced with your actual domain and test_project with the actual name of your project) you will be able to access the Symfony installation.

Keep in mind that if you have not allowed your IP address you should do so by editing the code of the app_dev.php file located in the project folder under the web/ subfolder. When editing the file you will need to find the following line:
|| !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1','YOUR_IP_ADDRESS'
, 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
This should be on line 14 and there you will need to edit “YOUR_IP_ADDRESS
” with your actual IP address which you should be able to check via some IP checking tool.
Conclusion
Composer is a must have tool for all those folks who need to build their projects in the speed of light simply skipping the process of deploying multiple packages, plugins, configurations and so on. Thanks to our well-experienced System Administrators we are able to provide Composer on all our packages from this point on.
Do you have any other suggestions for tools you would like us to implement on our Shared Hosting Environment? Let us know what you think about the Composer use and how beneficial is that for your PHP projects.
The latest tips and news from the industry straight to your inbox!
Join 30,000+ subscribers for exclusive access to our monthly newsletter with insider cloud, hosting and WordPress tips!
No Comments