Symfony_quick_tour_2.1(1).pdf

(408 KB) Pobierz
The Quick Tour
for Symfony 2.1
generated on January 8, 2013
What could be better to make up your own mind than to try out Symfony yourself? Aside from
a little time, it will cost you nothing. Step by step you will explore the Symfony universe. Be
careful, Symfony can become addictive from the very first encounter!
967058538.026.png 967058538.027.png 967058538.028.png 967058538.029.png 967058538.001.png 967058538.002.png 967058538.003.png 967058538.004.png 967058538.005.png
The Quick Tour (2.1)
This work is licensed under the “Attribution-Share Alike 3.0 Unported” license ( http://creativecommons.org/
licenses/by-sa/3.0/ ).
You are free to share (to copy, distribute and transmit the work), and to remix (to adapt the work) under the
following conditions:
Attribution : You must attribute the work in the manner specified by the author or licensor (but
not in any way that suggests that they endorse you or your use of the work).
Share Alike : If you alter, transform, or build upon this work, you may distribute the resulting work
only under the same, similar or a compatible license. For any reuse or distribution, you must make
clear to others the license terms of this work.
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution
has been taken in the preparation of this work, neither the author(s) nor SensioLabs shall have any liability to
any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by
the information contained in this work.
If you find typos or errors, feel free to report them by creating a ticket on the Symfony ticketing system
( http://github.com/symfony/symfony-docs/issues ).
Based
on
tickets
and
users
feedback,
this
book
is
continuously updated.
Chapter 1
The Big Picture
Start using Symfony2 in 10 minutes! This chapter will walk you through some of the most important
concepts behind Symfony2 and explain how you can get started quickly by showing you a simple project
in action.
If you've used a web framework before, you should feel right at home with Symfony2. If not, welcome to
a whole new way of developing web applications!
Want to learn why and when you need to use a framework? Read the " Symfony in 5 minutes"
document.
Downloading Symfony2
First, check that you have installed and configured a Web server (such as Apache) with PHP 5.3.3 or
higher.
If you have PHP 5.4, you could use the built-in web server. The built-in server should be used only
for development purpose, but it can help you to start your project quickly and easily.
Just use this command to launch the server:
1 $ php -S localhost:80 -t /path/to/www
Listing 1-1
where "/path/to/www" is the path to some directory on your machine that you'll extract Symfony
into so that the eventual URL to your application is " http://localhost/Symfony/app_dev.php 1 ". You
can also extract Symfony first and then start the web server in the Symfony "web" directory. If you
do this, the URL to your application will be " http://localhost/app_dev.php 2 ".
1. http://localhost/Symfony/app_dev.php
2. http://localhost/app_dev.php
PDF brought to you by
generated on January 8, 2013
Chapter 1: The Big Picture | 4
967058538.009.png 967058538.010.png 967058538.011.png 967058538.012.png 967058538.013.png 967058538.014.png 967058538.015.png 967058538.016.png 967058538.017.png 967058538.018.png
Ready? Start by downloading the " Symfony2 Standard Edition 3 ", a Symfony distribution that is
preconfigured for the most common use cases and also contains some code that demonstrates how to use
Symfony2 (get the archive with the vendors included to get started even faster).
After unpacking the archive under your web server root directory, you should have a Symfony/ directory
that looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
www/ <- your web root directory
Symfony/ <- the unpacked archive
app/
Listing 1-2
cache/
config/
logs/
Resources/
bin/
src/
Acme/
DemoBundle/
Controller/
Resources/
...
vendor/
symfony/
doctrine/
...
web/
app.php
...
If you are familiar with Composer, you can run the following command instead of downloading
the archive:
1
2
3
4
$ composer.phar create-project symfony/framework-standard-edition path/to/install
2.1.x-dev
Listing 1-3
# remove the Git history
$ rm -rf .git
For an exact version, replace 2.1.x-dev with the latest Symfony version (e.g. 2.1.1). For details, see
the Symfony Installation Page 4
If you have PHP 5.4, you can use the built-in web server:
1
2
3
4
5
# check your PHP CLI configuration
$ php ./app/check.php
Listing 1-4
# run the built-in web server
$ php ./app/console server:run
Then the URL to your application will be " http://localhost:8000/app_dev.php 5 "
The built-in server should be used only for development purpose, but it can help you to start your
project quickly and easily.
3. http://symfony.com/download
4. http://symfony.com/download
PDF brought to you by
generated on January 8, 2013
Chapter 1: The Big Picture | 5
967058538.019.png 967058538.020.png 967058538.021.png 967058538.022.png 967058538.023.png 967058538.024.png 967058538.025.png
Zgłoś jeśli naruszono regulamin