(updated instructions to reference current version of symfony)
(Symfony syntax seems to have changed. Updating with the new equivalents that worked for me)
|Line 43:||Line 43:|
symfony project myproject
|Line 99:||Line 99:|
symfony app MyApp
Revision as of 23:17, 8 January 2011
|This article or section may require a cleanup.|
We are hoping to create articles that meet certain standards. Please discuss this issue on the talk page. Editing help is available.
What is Symfony?
Symfony is a web application framework for PHP5 projects. It aims to speed up the creation and maintenance of web applications, and to replace the repetitive coding tasks by power, control and pleasure.
The very small number of prerequisites make symfony easy to install on any configuration; you just need Category:UNIX or Windows with a web server and PHP 5 installed. It is compatible with almost every database system. In addition, it has a very small overhead, so the benefits of the framework don't come at the cost of an increase of hosting costs.
Using symfony is so natural and easy for people used to PHP and the design patterns of Internet applications that the learning curve is reduced to less than a day. The clean design and code readability will keep your delays short. Developers can apply agile development principles (such as Don't repeat Yourself (DRY), Keep It Simple Stupid (KISS) or the Extreme Programming (XP) philosophy) and focus on applicative logic without losing time to write endless XML configuration files.
Symfony is aimed at building robust applications in an enterprise context. This means that you have full control over the configuration: from the directory structure to the foreign libraries, almost everything can be customized. To match your enterprise's development guidelines, symfony is bundled with additional tools helping you to test, debug and document your project.
Last but not least, by choosing symfony you get the benefits of an active open-source community. It is entirely free and published under the MIT License.
Symfony is sponsored by Sensio, a French Web Agency well known for its innovative views on web development.
These instructions will wipe out whatever is in the target domain that you want to be your symfony project. Be careful and backup everything before starting.
Be sure to start in your home directory.
cd ~ wget http://www.symfony-project.org/get/symfony-1.4.5.tgz tar -zxvf symfony-1.4.5.tgz mv symfony-1.4.5 symfony
This will retreive Symfony, unarchive it, and put it into a friendly directory in your home directory.
Now, to make things easier on you, you'll want to add Symfony and php5 to your ~/.bash_profile
This will modify your path to firstly prefer php5 over the php4 command line interpreter and also add the symfony executable directory to your path. Symfony requires PHP 5, and throwing your symfony directory into your bash profile makes it easier when using symfony around your site.
Setting up your first Symfony site
First, create a directory to house your symfony projects, and then create a directory to house your symfony project.
mkdir ~/Symfony_Projects mkdir ~/Symfony_Projects/myproject
Now that that's complete, it's time to start using symfony. If you did not add symfony to your PATH, be sure to type the full path when using a symfony command.
cd ~/Symfony_Projects/myproject symfony generate:project myproject
This will output something like this -
X-Powered-By: PHP/5.2.1 Content-type: text/html >> dir+ ~/Symfony_Projects/myproject/test >> dir+ ~/Symfony_Projects/myproject/test/unit >> dir+ ~/Symfony...jects/myproject/test/functional >> dir+ ~/Symfony...ojects/myproject/test/bootstrap >> file+ ~/Symfony...project/test/bootstrap/unit.php >> file+ ~/Symfony...t/test/bootstrap/functional.php >> dir+ ~/Symfony_Projects/myproject/batch >> dir+ ~/Symfony_Projects/myproject/log >> dir+ ~/Symfony_Projects/myproject/plugins >> dir+ ~/Symfony_Projects/myproject/apps >> dir+ ~/Symfony_Projects/myproject/cache >> dir+ ~/Symfony_Projects/myproject/config >> file+ ~/Symfony...cts/myproject/config/propel.ini >> file+ ~/Symfony...cts/myproject/config/schema.yml >> file+ ~/Symfony...roject/config/rsync_exclude.txt >> file+ ~/Symfony.../myproject/config/databases.yml >> file+ ~/Symfony...myproject/config/properties.ini >> file+ ~/Symfony...cts/myproject/config/config.php >> dir+ ~/Symfony_Projects/myproject/doc >> dir+ ~/Symfony_Projects/myproject/lib >> dir+ ~/Symfony_Projects/myproject/lib/model >> dir+ ~/Symfony_Projects/myproject/data >> dir+ ~/Symfony_Projects/myproject/data/sql >> dir+ ~/Symfony_Projects/myproject/data/model >> dir+ ~/Symfony_Projects/myproject/web >> dir+ ~/Symfony_Projects/myproject/web/images >> dir+ ~/Symfony_Projects/myproject/web/uploads >> dir+ ~/Symfony...ts/myproject/web/uploads/assets >> dir+ ~/Symfony_Projects/myproject/web/css >> file+ ~/Symfony...ects/myproject/web/css/main.css >> dir+ ~/Symfony_Projects/myproject/web/js >> file+ ~/Symfony...ojects/myproject/web/robots.txt >> file+ ~/Symfony_Projects/myproject/web/.htaccess >> file+ ~/Symfony_Projects/myproject/symfony >> tokens ~/Symfony...cts/myproject/config/propel.ini >> tokens ~/Symfony...myproject/config/properties.ini >> tokens ~/Symfony...cts/myproject/config/propel.ini >> tokens ~/Symfony...cts/myproject/config/config.php >> chmod 777 ~/Symfony_Projects/myproject/cache >> chmod 777 ~/Symfony_Projects/myproject/log >> chmod 777 ~/Symfony_Projects/myproject/web/uploads >> chmod 777 ~/Symfony_Projects/myproject/symfony >> chmod 777 web/uploads/assets
Before you can see anything, you will need to setup your first Symfony Application (which creates the default index.php stuff)
symfony generate:app MyApp
If you happen to get an error, ensure that ~/symfony/data/bin/symfony has executable permissions (744)
Finishing up the setup process
At this point, you're almost done. All that's left is to create a few symbolic links. Be careful when typin this command - there should not be any forward-slashes at the end of any of the directories.
ln -sf ~/symfony/data/web/sf ~/Symfony_Projects/myproject/web/sf ln -sf ~/Symfony_Projects/myproject/web/* ~/myproject.com
First symbolic link sets up a link to forward the base artwork for the administration pages of Symfony to your project, and the second links the web directory of your symfony project to the domain of your choosing.
Alternative Method using symfony freeze
If you develop your symfony application locally, you can use a much simpler method without installing anything. Run:
on your local machine. This will copy all symfony files of your current symfony installation into your project. You can now upload your project by FTP and it's ready to run. Make sure you point your web directory to the "web" subfolder.
To remove the symfony files from your project, simply run:
Your previous settings will be restored.
Dreamhost stats with symfony
Your new symfony site is unlikely to provide you with access to the standard Dreamhost stats page -- at http://mysite.com/stats. This is due to the .htaccess file in symfony's web directory, which routes all in-coming calls through the default controller. You can edit this file though, as described in Making_stats_accessible_with_htaccess, to return access to the stats pages.
More Information can be found here: The Definitive Guide to Symfony