Call (from translator)
Symfony is one of those PHP5 frameworks that attracts with its sufficient documentation, a variety of plug-ins, updates, announcements of new versions and many others.
Unfortunately, there is little documentation in Russian. Many reserved domains like
http://symfony-project.ru/ only have one phrase - “It will be soon”. And and for a long time already.
On the project itself
http://symfony-project.org/ in the documentation section you can see our tricolor only in the “Cookbook” section.
So, I challenge and intend to do the translation. I think it makes no sense to translate the API, the book is too much for me so far (but this is temporary, I can take it as well). And we will begin to translate
Askeet Tutorial . If the first translation is accepted, I will transfer it further. Every day I do not promise, but I will try to post on the article on weekdays
Call (from the author)
The symfony Advent Calendar is a collection of 24 lessons published daily from December 1st until Christmas. That's right, everyone, including the weekend, will publish a new lesson. Each lesson should not take more than an hour and will give us the opportunity to observe the advancing development of Web 2.0 applications from A to Z. At Christmas, the final version of the application will appear online, and the source code will be open. The application will be practical, interesting, useful and fun.
24 times an hour is a day and this is the maximum time, in our opinion, that a programmer should spend on learning symfony. Every day new features will be added to the application and the main advantage of this development is to consider the benefits of symfony functionality, just like getting good practice in developing web applications for symfony. Every day, you will be aware of how quickly and effectively develop a symfony web application ... And you will want to know more.
Considering that it will not be enough to cope only with this and given that we are lazy dudes - we have nothing planned for 21 days - the winter season. What is the point? What the community will require, we will add to the app on this day. Without preparation. And make it work. It will be a hire-symfony-guru-on-a-day.
The Project
The application being developed can be the usual “show-and-tell”, a to-do list, a phone book or a bookstore. But we want to use symfony in an original project, useful, with a bunch of fichets and ryushechek and a serious size. Our task is to prove that symfony can be used in difficult situations, in the development of professional applications with its own style and twist.
We hope that people will use the application to show that a symfony project can handle heavy loads. Therefore, the application must be relevant and meet existing needs or create new ones. The launch of the site will be a real test of strength. We will need you, dear readers, in order to dig / climb / chat on the site and discuss the meaning of life in order to check the maximum load.
We will keep the essence of the project for the next day. We have a lot of work without describing a full-fledged Web-2.0 application. Still name is required. Let's call it Askeet.
')
What do we have today?
The tasks for today are: to display the application page in a browser and to configure a professional development environment.
It will be easy for those who have already read other lessons and not too difficult for others. And everyone will find something new.
Suppose you are using a Unix system with Apache, Mysql and PHP5 installed. If you work under Windows - do not panic. Everything will work fine, just have to enter a few additional directives in the command line.
Unix commands can be very useful in Windows. If you want to use tools like tar, gzip or grep — on Windows — install Cygwin . Official documentation is a bit different, a good guide can be found here . Extremes can also try Windows Services for Unix.
Install symfony
The easiest way is to use the
PEAR package. However, to use the channels and access the symfony channel, you will need to upgrade PEAR to version 1.4.0 or more (unless you are using PHP5.1.0, you already have PEAR 1.4.5)
$ pear upgrade PEARHave a problem using PEAR? Read the chapter
Running Symfony .
Now you can add the 'symfony' channel:
$ pear channel-discover pear.symfony-project.comNow you are ready to install symfony and all dependencies:
$ pear install symfony / symfonyIf you are interested in a particular version:
$ pear upgrade symfony / symfony-1.0.11And so you can check whether symfony is installed and see its version (-V capital)
$ symfony -VIf you are interested in the symfony command line features, type
$ symfony -T and see the list of available options. You can also read
Running Symfony and find out how to install symfony from tgz or the svn repository. The community also describes a non-PEAR installation method in the
symfony wiki.Project installation
In symfony, applications that have common data models are put into projects. The Backsnd (admin) and frontend (the site itself) will be implemented in the “Requeska” project - these are 2 applications. The project is the foundation of the application and must be created first. All you need is a project folder and command line:
$ mkdir / home / sfprojects / askeet
$ cd / home / sfprojects / askeet
$ symfony init-project askeetIt’s time to create a frontend for symfony:
$ symfony init-app frontendWow how fast.
Windows users are strongly advised to keep projects with paths that do not contain spaces.
Installing a web service
Now it's time to make changes to the Apache config to make the project available. It is highly recommended to create an application on a virtual host, which we will do.
open the httpd.conf file in your apache configuration folder and add the following:
NameVirtualHost 127.0.0.1:80<VirtualHost 127.0.0.1:80>ServerName askeet
DocumentRoot "/ home / sfprojects / askeet / web"
DirectoryIndex index.php
Alias ​​/ sf / usr / local / lib / php / data / symfony / web / sf
<Directory "/ home / sfprojects / askeet / web">
AllowOverride All</ Directory>
</ Virtualhost>
The sf alias should point to the path to symfony in the PEAR folder. To define it enter pear config-show . Symfony applications must have access to this directory in order to use some image and js files to properly display the debag panel and ajax helpers.
In Windows, Alias ​​needs to be replaced with this:
Alias ​​/ sf "C: \ php \ pear \ data \ symfony \ web \ sf"If nothing works, it may be worth adding rights to the aliased / sf folder. The code below is from the working copy of Windows
WAMP :
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
ServerName askeet
DocumentRoot "C: / sfprojects / askeet / web"
DirectoryIndex index.php
Alias ​​/ sf "C: / wamp / php / PEAR / data / symfony / web / sf"
<Directory "C: / sfprojects / askeet / web">
AllowOverride All
Allow from All
</ Directory>
<Directory "C: / wamp / php / PEAR / data / symfony / web / sf">
AllowOverride All
Allow from All
</ Directory>
</ Virtualhost>
Set domain name
Install the locally domain name askeet.
In Linux, this is done via the / etc / hosts file. In Windows XP, this file is in C: \ WINDOWS \ system32 \ drivers \ etc \.
Add the following:
127.0.0.1 askeetIf you do not want to work with a new host, simply change the Listen parameter to another port. So you can continue to use the localhost domain.
Test the new config?
Restart Apache and go to
askeetIf you see the symfony welcome page, we can congratulate you!
To access the developer environment, go to:
askeet / frontend_dev.phpAt the top of the page you should see a debug panel and small icons proving that the configuration is correct.

If /frontend_dev.php/ is displayed in the same way as /index.php/, then most likely there is an error in the http.conf configuration in the mod_rewrite area. Or maybe you just need to make symfony cc
Iis
Installation on IIS is slightly different from the usual. Find the installation method in
this lesson.Subversion
One of the main principles of lazy dudes is not to worry about breaking the code. SVN helps us:
- work fast
- return to the previous version of the code if the changes were not effective
- work a few people in command
- have access to daily changes.
we will use
Subverstion for this purpose
It will assume that you have already installed the svn-server or have access to it.
To begin with, we will create a repository for the “Demand” project:
$ svnadmin create $ SVNREP_DIR / askeet
$ svn mkdir -m "layout creation" file: /// $ SVNREP_DIR / askeet / trunk file: /// $ SVNREP_DIR / askeet / tags file: /// $ SVNREP_DIR / askeet / branches
For newbies Subversion. These two lines create an svn repository. The second line creates the directory structure for the repository.
All the main working code will be stored in the trunk. Tags contains releases of the main version (version 1, version 2, etc.).
Branches contain code that is not too different from the main working code. Very often, branches merge back to the trunk.
For example, the main trunk development can continue until a new feature is fully tested and fixed.
in branch. After testing is completed, the branch is merged into the trunk with all changes to the branch code. Svn gives powerful
tools to assist in this process.
Next, you need to do the first import, bypassing the temporary files of the cache / and log / directories
$ cd / home / sfprojects / askeet
$ rm -rf cache / *
$ rm -rf log / *
$ svn import -m "initial import". file: /// $ SVNREP_DIR / askeet / trunk
For newbies to svn. The fourth line imports the file “and the directory“ Demand ”in the directory of the trunk repository. Now the code is
under version control
Now the code is under version control, but the code must be obtained (verified) in order for SVN to be able to follow the changes.
Back up the project directory and use SVN checkout for the working version:
$ cd / home / sfprojects
$ mv askeet askeet.origin
$ svn co file: /// $ SVNREP_DIR / askeet / trunk / askeet /
$ ls askeet
If everything is okay, you can delete the backup. We will not need it anymore:
$ rm -rf askeet.origin
For newbies to svn. The code from the trunk is now in our working directory askeet /. This code we will modify and improve.
On the SVN side, this code is called the “working copy”. SVN monitors changes in the code when it is sent (commit)
It remains to configure only one moment. When you send the working code to the repository, they can also be copied.
unwanted files, for example from the cache and log folders of your project. Therefore, you need to specify the ignore list for this project:
$ cd / home / sfprojects / askeet
$ svn propedit svn: ignore cache
The standard text editor should start. And so we point to the files and folders that will be
ignored on commit:
*Save and exit. That's all.
Repeat the procedure for the log folder:
$ svn propedit svn: ignore log
And enter only:
*Now make sure that the directories have the right permissions so that the web server can write to these directories:
$ chmod 777 cache
$ chmod 777 log
Windows users can use the great TortoiseSVN client.
to manage the repository. But remember - never delete directories through the browser Windows.
Use the TortoiseSVN (Rename, Delete) menu to make svn know what happened. Otherwise, instead of kommit you will have
make an update and return to the old version.
See you!
Well, that was an hour! We talked and talked ... and ... nothing new was shown to the future symfony followers. But let's take a look at the tasks of the second day of the symfony researcher:
- what the application does
- creating a model of data and generating an object-oriented representation
- work with the module
I hope you will come back to us!
UPD: At the request of workers - a piece of SVN is translated