document
TRANSCRIPT
7/31/2019 www-ens-ro
1/4
Previous Next
Symfony2 Jobeet Day 1: Starting up the Project
Today we will setup the development environment, install Symfony2 and display a page of the application in a web browser. First of all,
you need to check that your computer has a friendly working environment for web development. At a minimum, you need a web server
(Apache, for instance), a database engine (MySQL), and PHP 5.3.2 or later.
Download and install Symfony2
Prepare a directory on your web server where you want to install the new project. We will name this directory jobeet as the name of our
future website. Then go to http://symfony.com/download, choose Symfony Standard (the version with vendors) and download it (at the
moment of writing this tutorial, the latest Symfony version was 2.0.11). After downloading, unpack the archive and copy the contents of
Symfony dir to your project directory. You should now have something like this:
Web Server Configuration
A good web practice is to put under the web root directory only the files that need to be accessed by a web browser, like stylesheets,
JavaScripts and images. By default, its recommended to store these files under the web/ sub-directory of a symfony project.
Posted on March 22, 2012
ENSEntertainment, New s, Software
Search
Home Web Development About ENS Contact
converted by Web2PDFConvert.com
http://www.ens.ro/category/web-development/http://www.ens.ro/about/http://www.ens.ro/contact/http://www.ens.ro/http://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://www.ens.ro/wp-content/uploads/2012/03/jobeet_screen_001.pnghttp://symfony.com/downloadhttp://www.ens.ro/2012/03/24/symfony2-jobeet-day-2-the-project/http://www.ens.ro/2012/03/21/jobeet-tutorial-with-symfony2/http://www.ens.ro/contact/http://www.ens.ro/about/http://www.ens.ro/category/web-development/http://www.ens.ro/http://www.ens.ro/http://www.ens.ro/7/31/2019 www-ens-ro
2/4
To configure Apache for your new project, locate and open the httpd.conf configuration file and add the following configuration at the end:
Change the above configuration to reflect your setup and then restart your web server.
This is the standard way to define a new virtual host in Apache. Depending on your server configuration or Apache version, some things
might be slightly different. For example in Ubuntu you have to create a new file in the folder /etc/apache2/sites-enabled/ named jobeet
with the above content.
The domain namejobeet.localused in the Apache configuration has to be declared locally. If you run a Linux system, it has to be done in
the /etc/hosts file. If you run Windows, this file is located in the C:\WINDOWS\system32\drivers\etc\ directory. Add in the following line:
Test the Symfony2 Installation
After restarting Apache, open a browser window and type in http://jobeet.local/app_dev.php. You should see the following page:
To avoid some headaches further down the l ine, check that your configuration can run a Symfony2 project smoothly by requesting the
following URL: http://jobeet.local/config.php. Make sure you dont have any Major Problems listed, and follow the optional
recommendations listed (if any).
Symfony2 console
Just like Symfony 1.x, Symfony2 comes with the console component tool that you will use for different tasks. To see a list of things it can
do for you type at the command prompt:
Creating the Application Bundle
As you know, a Symfony2 project is made up of bundles. Even the Symfony framework is a bundle. To create a new bundle for our
application run from the command line:
ServerName jobeet.localDocumentRoot /home/dragos/work/jobeet/webDirectoryIndex app.phpErrorLog /var/log/apache2/jobeet-error.logCustomLog /var/log/apache2/jobeet-access.log combined
AllowOverride AllAllow from All
127.0.0.1 jobeet.local
php app/console list
converted by Web2PDFConvert.com
http://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://www.ens.ro/wp-content/uploads/2012/03/jobeet_screen_002.png7/31/2019 www-ens-ro
3/4
Symfony2 Jobeet Day 2: The Project
The generator will ask you some questions before generating the bundle. Here are the questions and the answers (all except one are the
default answers):
Bundle namespace [Ens/JobeetBundle]: Ens/JobeetBundle
Bundle name [EnsJobeetBundle]: EnsJobeetBundle
Target directory [/home/dragos/work/jobeet/src]: /home/dragos/work/jobeet/src
Configuration format (yml, xml, php, or annotation) [yml]: yml
Do you want to generate the whole directory structure [no]?yes
Do you confirm generation [yes]? yes
Confirm automatic update of your Kernel [yes]? yes
Confirm automatic update of the Routing [yes]? yes
Clear the cache after generating the new bundle with:
The new Jobeet bundle can be now found in the src directory of out project: src/Ens/JobeetBundle. The bundle generator made a
DefaultController with an index action. You can access this in your browser: http://jobeet.local/hello/jobeet or
http://jobeet.local/app_dev.php/hello/jobeet
The Environments
As Symfony 1.x, Symfony2 also has different environments. If you look in the projects web directory, you will see two php files: app.php
and app_dev.php. These files are called front controllers; all requests to the application are made through them. The app.php file is for
production environment and app_dev.php is used by web developers when they work on the application in the development
environment. The development environment will prove very handy because it will show you all the errors and warnings and the Web
Debug Toolbar the developers best friend.
Thats all for today. See you on the next day of this tutorial when we will talk about what exactly the Jobeet website will be about!
This entry was posted in English, PHP, Web Development by Dragos Holban. Bookmark the permalink.
php app/console generate:bundle --namespace=Ens/JobeetBundle --format=yml
php app/console cache:clear --env=prodphp app/console cache:clear --env=dev
Leave a Reply
Your email address will not be published. Required fields are marked *
Post Comment
Name *
Email *
Website
Comment
converted by Web2PDFConvert.com
http://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://www.ens.ro/author/dragos/http://www.ens.ro/category/web-development/http://www.ens.ro/category/web-development/php/http://www.ens.ro/category/english/http://www.ens.ro/2012/03/24/symfony2-jobeet-day-2-the-project/7/31/2019 www-ens-ro
4/4
Proudly powered by WordPress
converted by Web2PDFConvert.com
http://www.web2pdfconvert.com/?ref=PDFhttp://www.web2pdfconvert.com/?ref=PDFhttp://wordpress.org/