• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Running Symfony
 

Running Symfony

on

  • 3,937 views

The Definitive Guide to symfony

The Definitive Guide to symfony

Statistics

Views

Total Views
3,937
Views on SlideShare
3,927
Embed Views
10

Actions

Likes
0
Downloads
65
Comments
0

2 Embeds 10

http://www.slideshare.net 6
http://wildanm.wordpress.com 4

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Running Symfony Running Symfony Presentation Transcript

    • Wildan Maulana | wildan [at] tobethink.com #3 The Definitive Guide to symfony Running Symfony Doc. v. 0.1 - 14/04/09
    • Requirement
      • Symfony requires at least PHP 5.2. Make sure you have it installed by opening a command line and typing this command:
      > php -v PHP 5.2.6-2ubuntu4 with Suhosin-Patch 0.9.6.2 (cli) (built: Oct 14 2008 20:06:32) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
    • Symfony Installation Method
      • Use sandbox if you just wanna see what is symfony capable of
      • Use PEAR installation method, it is recommended for most people
      • Use Subversion (SVN) installation, it is meant to be used by advanced PHP developers, who want to take advantage of the latest patches, add features of their own, and/or contribute to the symfony project. Btw, I prefer using SVN installation method
    • Installing the Sandbox
      • The sandbox is a simple archive of files. It contains an empty symfony project including all the required libraries (symfony, lime, Prototype with Scriptaculous, Doctrine and Propel with Phing), a default application, and basic configuration. It will work out of the box, without specific server configuration or any additional packages.
      • Download from : http://www.symfony-project.org/get/sf_sandbox_1_2.tgz
        • Unpack it to the root web directory (I assume you to use sf_sandbox/ directory)
        • Test the installation : > php symfony -V You will see sandbox version number : symfony version 1.2.0 (/path/to/the/symfony/lib/dir/used/by/the/sandbox)
      • Try to browse the sandbox by requesting this URL : http://localhost/sf_sandbox/web/frontend_dev.php/
    • Installing symfony Libraries
      • Using symfony PEAR package
      • Using Subversion (SVN)
    • Installing the symfony PEAR Package
      • Add the symfony channel to PEAR > pear channel-discover pear.symfony-project.com
      • To see the libraries available in this channel, type the following: > pear remote-list -c symfony
      • Now you are ready to install the latest stable version of symfony. Issue this command: > pear install symfony/symfony
      • downloading symfony-1.2.0.tgz ...
      • Starting to download symfony-1.2.0.tgz (1,283,270 bytes)
      • .................................................................
      • .................................................................
      • .............done: 1,283,270 bytes
      • install ok: channel://pear.symfony-project.com/symfony-1.2.0
      • Check that the installation succeeded > symfony -V
      • symfony version 1.2.0 (/path/to/the/pear/symfony/lib/dir)
    • Installing the symfony PEAR Package
      • The symfony libraries are now installed in directories as follows:
        • $php_dir/symfony/ contains the main libraries.
        • $data_dir/symfony / contains the web assets used by symfony default modules.
        • $doc_dir/symfony/ contains the documentation.
        • $test_dir/symfony/ contains symfony core unit and functional tests.
      • The _dir variables are part of your PEAR configuration. To see their values, type the following:
        • > pear config-show
    • Checking Out symfony from the SVN Repository
      • # > mkdir /path/to/symfony
      • # > cd /path/to/symfony
      • # > svn checkout http://svn.symfony-project.com/tags/RELEASE_1_2_0/
      • > php /path/to/symfony/data/bin/symfony -V
      • symfony version 1.2.0 (/path/to/the/svn/symfony/lib/dir)
      <?php require_once '/path/to/symfony/lib/autoload/sfCoreAutoload.class.php'; sfCoreAutoload::register(); class ProjectConfiguration extends sfProjectConfiguration { // ... }
    • Setting Up an Application
      • Creating the Project
      • Creating the Application
    • Creating Project For a PEAR installation, issue these commands: > mkdir ~/myproject > cd ~/myproject > symfony generate:project myproject For an SVN installation, create a project with these commands: > mkdir ~/myproject > cd ~/myproject > php /path/to/symfony/data/bin/symfony generate:project myproject apps/ cache/ config/ data/ doc/ lib/ log/ plugins/ test/ web/ Symfony will create a directory structure that looks like this:
    • Creating the Application
      • The project is not ready for viewing before you create at least one application in it.
      • To initialize application use the symfony generate:app command >php symfony generate:app frontend
      • This will create a frontend/ directory in the apps/ folder of the project root, with a default application configuration and a set of directories ready to host the file of your website:
      apps/ frontend/ config/ i18n/ lib/ modules/ templates/ web/ index.php frontend_dev.php index.php -> front controller in production environment frontend_dev.php -> front controller in development environment
    • Configuring the Web Server
      • There are several cases :
        • Setting Up a Virtual Host
        • Setting Up an Alias
        • Configuring a Shared-Host Server
    • Setting Up a Virtual Host <VirtualHost *:80> ServerName myapp.example.com DocumentRoot &quot;/home/steve/myproject/web&quot; DirectoryIndex index.php Alias /sf /$sf_symfony_data_dir/web/sf <Directory &quot;/$sf_symfony_data_dir/web/sf&quot;> AllowOverride All Allow from All </Directory> <Directory &quot;/home/steve/myproject/web&quot;> AllowOverride All Allow from All </Directory> </VirtualHost> Don't fortget to setup your DNS entry for your application address first
    • Setting Up an Alias
    • Configuring a Shared-Host Server
      • This is a little trickier, since host usually has spesific directory layout that you can't change
    • .htaccess Options +FollowSymLinks +ExecCGI <IfModule mod_rewrite.c> RewriteEngine On # uncomment the following line, if you are having trouble # getting no_script_name to work #RewriteBase / # we skip all files with .something #RewriteCond %{REQUEST_URI} ..+$ #RewriteCond %{REQUEST_URI} !.html$ #RewriteRule .* - [L] # we check if the .html version is here (caching) RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f # no, so we redirect to our front web controller RewriteRule ^(.*)$ index.php [QSA,L] </IfModule>
    • Browse Your New App http://www.example.com/frontend_dev.php/
    • Troubleshooting
      • Parse error, unexpected ',', expecting '(' in .../symfony.php on line 19.
      • Allowed memory size of 8388608 bytes exhausted
      • Strict Standards: Implicit cloning object of class 'sfTimer'because of 'zend.ze1_compatibility_mode'
      • sfCacheException [message] Unable to write cache file&quot;/usr/myproject/cache/frontend/prod/config/config_config_handlers.yml.php&quot;
      • The include path of your system must include the path to the php command, and the include path of your php.ini must contain a path to PEAR (if you use PEAR).
      • Sometimes, there is more than one php.ini on a server's file system (for instance, if you use the WAMP package). Call phpinfo() to know the exact location of the php.ini file used by your application.
    • Symfony Resources
      • The symfony installation forum (http://www.symfony-project.org/forum/)
      • The archives of the users mailing-list (http://groups.google.fr/group/symfony-users)
      • The symfony wiki (http://trac.symfony-project.org/
    • Source Versioning
      • > svnadmin create $SVNREP_DIR/myproject
      • > svn mkdir -m &quot;layout creation&quot; file:///$SVNREP_DIR/myproject/trunk file:///$SVNREP_DIR/myproject/tags file:///$SVNREP_DIR/myproject/branches
      • > cd ~/myproject
      • rm -rf cache/*
      • rm -rf log/*
      • svn import -m &quot;initial import&quot; . file:///$SVNREP_DIR/myproject/trunk
      • > svn ls file:///$SVNREP_DIR/myproject/trunk/
      • > cd ~
      • > mv myproject myproject.origin
      • > svn co file:///$SVNREP_DIR/myproject/trunk myproject
      • > ls myproject
      • > cd ~/myproject
      • > chmod 777 cache
      • > chmod 777 log
      • > svn propedit svn:ignore log
      • > svn propedit svn:ignore cache
      • > export SVN_EDITOR=<name of editor>
      • > svn propedit svn:ignore log
      • > svn propedit svn:ignore cache
      • Write * , save and quit.
      • You're finished
    • Summary
      • For symfony 1 st time user, your best option is using the sandbox version
      • For real development, consider to use the SVN version
      • Once your project is initiated, it is a good habit to start a version-control process.
    • Q&A
    • Reference
      • The Definitive Guide to symfony, Fabien Potencier , Apress