
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Install and Get Started with Symfony 2 on Ubuntu
Symfony is a full-stack, open-source PHP framework. It’s well known for its independent components which can be easily integrated into any other PHP project. The Symfony framework is suitable for building personal home page applications of any length, consisting of console programs supposed to run only at the command line. This article explains about – How to install and get started with symfony 2 on Ubuntu.
Before we get started out, we’ll want to put in PHP for the command line environment. To install the php7.0-cli
package, use the following command-
$ sudo apt-get install php7.0-cli
You should now have PHP installed on your server. To verify, use the following command –
$ php -v
The sample output should be like this –
PHP 7.0.4-7ubuntu2 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Symfony requires that the option date.timezone is set in your php.ini file. To open php.ini file, use the following command –
$ sudo nano /etc/php/7.0/cli/php.ini
The sample output should be like this –
[PHP] ;;;;;;;;;;;;;;;;;;; ; About php.ini ; ;;;;;;;;;;;;;;;;;;; ; PHP's initialization file, generally called php.ini, is responsible for ; configuring many of the aspects of PHP's behavior. ; PHP attempts to find and load this configuration from a number of locations. ; The following is a summary of its search order: ; 1. SAPI module specific location. ; 2. The PHPRC environment variable. (As of PHP 5.2.0) ; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0) ; 4. Current working directory (except CLI) ; 5. The web server's directory (for SAPI modules), or directory of PHP ; (otherwise in Windows) ; 6. The directory from the --with-config-file-path compile time option, or the ; Windows directory (C:\windows or C:\winnt) ; See the PHP docs for more specific information. .......................................................................................
Search for the line containing date.timezone. Uncomment the directive by removing the ; sign in the beginning of the line, and add the appropriate timezone for your application as shown here –
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = Asia/Kolkata
Installing the Symfony
To install symfony, use the following command which will download the Symfony installer and place it on your /usr/local/bin path –
$ sudo curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony
Now, you’ll need to make the script executable with the following command –
$ sudo chmod a+x /usr/local/bin/symfony
To test the Symfony Installer,use the following command-
$ symfony
The sample output should be like this –
Symfony Installer (1.5.1) ========================= This is the official installer to start new projects based on the Symfony full-stack framework. To create a new project called blog in the current directory using the latest stable version of Symfony, execute the following command: symfony new blog Create a project based on the Symfony Long Term Support version (LTS): symfony new blog lts Create a project based on a specific Symfony branch: symfony new blog 2.3 Create a project based on a specific Symfony version: symfony new blog 2.5.6 Create a demo application to learn how a Symfony application works: symfony demo Updating the Symfony Installer ------------------------------ New versions of the Symfony Installer are released regularly. To update your installer version, execute the following command: symfony self-update
Creating a New Symfony Project
To create a symfony project, use the following command –
$ symfony new tutorialspoint
The above command tutorialspoint is the project name. The sample output should be like this –
Preparing for project... ? Symfony 3.0.6 was successfully installed. Now you can: * Change your current directory to /home/linux/tutorialspoint * Configure your application in app/config/parameters.yml file. * Run your application: 1. Execute the php bin/console server:run command. 2. Browse to the http://localhost:8000 URL. * Read the documentation at http://symfony.com/doc
To run the application, use the following command –
$sudo php bin/console server:run
The sample output should be like this –
[OK] Server running on http://127.0.0.1:8000 // Quit the server with CONTROL-C.
Now open your web browser and add the following url-
http://your_server_ip:8000
The sample output should be like this –
To quit from the server, use Ctrl+C in command line.That’s it. After this article, you will be able to understand – How to Install and Get Started with Symfony 2 on Ubuntu, we will come up with more Linux based tricks and tips. Keep reading!