Development

BeginningSymfonyWithPear

You must first sign up to be able to contribute.

Version 14 (modified by Paul.Lomax, 10 years ago)
Phing instructions changed to use phing channel

Beginning Symfony Project with XAMPP and Pear

The exact process that I had to go through from the very beginning. I like the description for InstallingSymfonyWithoutPear?, but the one in the documentation, using Pear left me unable to get things working. It helped immensely, but I found that that show stopper was actually getting Pear correctly configured with xampp on windows. So unless you are trying what I tried, the other instructions will probably work for you as well.

I posted this just so that the complete trials of a beginner in symfony where documented for other beginners. Hope this helps, spascoe.

Assumptions

  1. Windows XP SP2 development system.
  2. Eclipse 3.1 and PHPEclipse as PHP editor.
  3. Subversion is installed on a server named pdev -- don't worry, its hidden from you all :)
  4. Windows Share svnprivate pointing to the repository
  5. TortoiseSVN is installed on dev box.
  6. I will be able to get xampp 1.5.0 working correctly (I did, see the notes below.)
  7. c:\dev is the location of the Eclipse Workspace
  8. c:\dev\PlannedCRM is the location of the Symfony project. My sample app is named Employee and my first module is Home.

Create the Subversion Repository

  • Open Windows Explorer
  • Point to \\pdev\svnprivate
  • Create the repository directory, PlannedCRM
  • Right-click on PlannedCRM and choose TortoiseSVN/CreateRepository Here
  • Select Native Filesystem (FSFS) and click OK.

This create the empty repository.

Create Local Sandbox

Next up is the creation of your local sandbox, or checked out copy of the Repository. I did the following:

  • Open Windows Explorer
  • Navigate to c:\dev
  • Right-click in empty space in the right-hand pane.
  • Choose SVN Checkout
  • Enter: https://pdev/svn/PlannedCRM for the URL of repository
  • Enter: c:\dev\PlannedCRM for the Checkout Directory
  • Click OK
  • Accept the prompt to create the folder c:\dev\PlannedCRM
  • Wait for checkout to complete and click OK

Create repository layout

Typical svn repositories contain at the root, three directories named branches, tags, and trunk. Trunk is where the main work goes on. You need to create this layout, commit it to the repository, then throw away this sandbox and get a new one pointing at trunk. The following shows how to do this, in Windows:

Create Layout
  • In Windows Explorer, navigate to c:\dev\PlannedCRM
  • Create three directories, named branches, tags, and trunk
  • In the Folder list, right-click on the c:\dev\PlannedCRM folder, choose TortoiseSVN/Add
  • You will see a dialog box with the five new directories checked. Click OK to add them to the repository (pending add, that is).
  • Again, right-click on the c:\dev\PlannedCRM folder, choose SVN Commit to commit the changes to the repository. You will be prompted to enter a log message. Enter layout creation. Click OK to save the folders into the svn repository.
  • Wait for commit to finish and click OK.
Throw away sandbox and get new
  • Now, right-click on c:\dev\PlannedCRM and choose Delete.
  • Next, Right-click on c:\dev, in the Folder pane.
  • Choose SVN Checkout.
  • Enter https://pdev/svn/plannedcrm/trunk for the URL of repository.
  • Enter c:\dev\PlannedCRM for the Checkout directory.
  • Click OK and accept the prompt to create the directory.

You will now have the trunk of the repository checked out and ready to begin working in it.

Install XAMPP for Windows

The XAMPP for Windows installation as of 11/20/2005 contains:

  • apache 2.0.55
  • mysql 5.0.15
  • OpenSSL 0.9.8a
  • PHP 5.0.5 and PHP 4.4.1
  • Mercury Mail Transport
  • Filezilla

The primary item to install is XAMPP itself. Download the 7-Zip self-extracting exe. When you run it, you will be prompted for an extract directory. Enter C:\. It will create the xampp directory.

You may install the PERL and Python addon's, but they aren't necessary. If you do choose to install the PERL and Python modules be sure to specify C:\xampp as the extract directory.

Also, install them before running c:\xampp\setup_xampp.bat.

Set PHP Paths

Add c:\xampp\php to the end of the PATH in ControlPanel/System/Advanced/EnvironmentVariables

Check PHP's PEAR Installation

First run pear config-show.

C:\xampp>pear config-show
CONFIGURATION (CHANNEL PEAR.PHP.NET):
=====================================
Auto-discover new Channels     auto_discover    <not set>
Default Channel                default_channel  pear.php.net
HTTP Proxy Server Address      http_proxy       <not set>
PEAR server [DEPRECATED]       master_server    pear.php.net
Default Channel Mirror         preferred_mirror pear.php.net
Remote Configuration File      remote_config    <not set>
PEAR executables directory     bin_dir          C:\xampp\php
PEAR documentation directory   doc_dir          C:\xampp\php\pear\docs
PHP extension directory        ext_dir          C:\xampp\php\ext
PEAR directory                 php_dir          C:\xampp\php\pear
PEAR Installer cache directory cache_dir        C:\xampp\tmp
PEAR data directory            data_dir         C:\xampp\php\pear\data
PHP CLI/CGI binary             php_bin          C:\xampp\php\php.exe
PEAR test directory            test_dir         C:\xampp\php\pear\tests
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  stable
Unix file mask                 umask            0
Debug Log Level                verbose          1
PEAR password (for             password         <not set>
maintainers)
Signature Handling Program     sig_bin          c:\gnupg\gpg.exe
Signature Key Directory        sig_keydir       C:\xampp\php\pearkeys
Signature Key Id               sig_keyid        <not set>
Package Signature Type         sig_type         gpg
PEAR username (for             username         <not set>
maintainers)
User Configuration File        Filename         C:\xampp\php\pear.ini
System Configuration File      Filename         C:\xampp\php\pearsys.ini

Run pear upgrade PEAR. This will probably fail, at least it does on XAMPP 1.5.0 pl1.

C:\xampp>pear upgrade PEAR
downloading PEAR-1.4.4.tgz ...
Starting to download PEAR-1.4.4.tgz (276,978 bytes)
.........................................................done: 276,978 bytes
permission denied (delete): \xampp\php\pear.bat
permission denied (delete): \xampp\php\peardev.bat
permission denied (delete): \xampp\php\pecl.bat
ERROR: commit failed

Found the problem after a little research. Open c:\xampp\php\pear.bat in notepad. Near the middle of the file you will see several lines like this:

ATTRIB +R %PHP_PEAR_BIN_DIR%\pear.bat >nul
ATTRIB +R %PHP_PEAR_BIN_DIR%\peardev.bat >nul
ATTRIB +R %PHP_PEAR_BIN_DIR%\pecl.bat >nul

Put a REM in front of all three commands, save the file and then run the pear upgrade pear again. It should work now.

Trying a pear symfony-beta install

Discover the 'symfony' channel.

pear channel-discover pear.symfony-project.com

Install symfony beta

pear install symfony/symfony-beta

This installs pake and symfony. Next phing needs to be installed, but it needs some configuration changes from the normal stuff.

pear channel-discover pear.phing.info

Followed by

pear install phing/phing

And you should see something like:

downloading phing-current.tgz ...
Starting to download phing-current.tgz (361,527 bytes)
.........................................................................done: 361,527 bytes
pear/phing requires package "pear/PhpDocumentor" (version >= 1.3.0RC3), installed version is 1.2.3
downloading VersionControl_SVN-0.3.0alpha1.tgz ...
Starting to download VersionControl_SVN-0.3.0alpha1.tgz (33,829 bytes)
...done: 33,829 bytes
downloading xdebug-2.0.0beta4.tgz ...
Starting to download xdebug-2.0.0beta4.tgz (228,343 bytes)
...done: 228,343 bytes
Attempting to download binary version of extension "xdebug"

Notice: Uninitialized string offset:  0 in PEAR\PackageFile\v2.php on line 205
parsePackageName(): invalid package name "" in "channel://pecl.php.net/-2.0.0beta4"
invalid package name/package file "Array"
Cannot initialize 'pecl/', invalid or missing package file
ERROR: failed to write C:\xampp\php\pear\docs\xdebug\.tmpChangelog
install ok: channel://pear.php.net/VersionControl_SVN-0.3.0alpha1

Now to the meat of the application startup

I think that symfony is finally installed correctly. Next thing to do is run the init-project command. So in a command prompt:

cd \dev\PlannedCRM
symfony init-project PlannedCRM

Gets the following output:

C:\dev\PlannedCRM>symfony init-project PlannedCRM
>> dir+      C:\dev\PlannedCRM\\batch
>> file+     C:\dev\PlannedCRM\\batch\.sf
>> dir+      C:\dev\PlannedCRM\\cache
>> file+     C:\dev\PlannedCRM\\cache\.sf
>> dir+      C:\dev\PlannedCRM\\config
>> file+     C:\dev\PlannedCRM\\config\apache.conf
>> file+     C:\dev\PlannedCRM\\config\config.php
>> file+     C:\dev\PlannedCRM\\config\doc_footer.html
>> file+     C:\dev\PlannedCRM\\config\doc_header.html
>> file+     C:\dev\PlannedCRM\\config\doxygen.cfg
>> file+     C:\dev\PlannedCRM\\config\propel.ini
>> file+     C:\dev\PlannedCRM\\config\properties.ini
>> file+     C:\dev\PlannedCRM\\config\rsync_exclude.txt
>> file+     C:\dev\PlannedCRM\\config\schema.xml.sample
>> dir+      C:\dev\PlannedCRM\\data
>> file+     C:\dev\PlannedCRM\\data\.sf
>> dir+      C:\dev\PlannedCRM\\data\model
>> file+     C:\dev\PlannedCRM\\data\model\.sf
>> dir+      C:\dev\PlannedCRM\\data\sql
>> file+     C:\dev\PlannedCRM\\data\sql\.sf
>> dir+      C:\dev\PlannedCRM\\doc
>> file+     C:\dev\PlannedCRM\\doc\.sf
>> dir+      C:\dev\PlannedCRM\\lib
>> file+     C:\dev\PlannedCRM\\lib\.sf
>> dir+      C:\dev\PlannedCRM\\log
>> file+     C:\dev\PlannedCRM\\log\.sf
>> file+     C:\dev\PlannedCRM\\SYMFONY
>> dir+      C:\dev\PlannedCRM\\web
>> file+     C:\dev\PlannedCRM\\web\.htaccess
>> dir+      C:\dev\PlannedCRM\\web\css
>> file+     C:\dev\PlannedCRM\\web\css\main.css
>> file+     C:\dev\PlannedCRM\\web\error.php
>> dir+      C:\dev\PlannedCRM\\web\images
>> file+     C:\dev\PlannedCRM\\web\images\.sf
>> dir+      C:\dev\PlannedCRM\\web\js
>> file+     C:\dev\PlannedCRM\\web\js\.sf
>> dir+      C:\dev\PlannedCRM\\web\uploads
>> file+     C:\dev\PlannedCRM\\web\uploads\.sf
>> dir+      C:\dev\PlannedCRM\\web\uploads\assets
>> file+     C:\dev\PlannedCRM\\web\uploads\assets\.sf
>> tokens    C:\dev\PlannedCRM\\config\apache.conf
>> tokens    C:\dev\PlannedCRM\\config\propel.ini
>> tokens    C:\dev\PlannedCRM\\config\properties.ini
>> tokens    C:\dev\PlannedCRM\\config\propel.ini
>> chmod 777 C:\dev\PlannedCRM/web/uploads\\assets
>> chmod 777 C:\dev\PlannedCRM\log
>> chmod 777 C:\dev\PlannedCRM\cache
>> chmod 666 C:\dev\PlannedCRM/web/uploads\\.sf
>> chmod 666 C:\dev\PlannedCRM/web/uploads\\assets\.sf
>> chmod 666 C:\dev\PlannedCRM/log\\.sf

This is encouraging, now I want to init-app my first app. I'll call it Employee because my sample app is a CRM product. So in the same command prompt:

symfony init-app Employee

Gets this result:

C:\dev\PlannedCRM>symfony init-app Employee
>> dir+      C:\dev\PlannedCRM/Employee
>> dir+      C:\dev\PlannedCRM/Employee\\config
>> file+     C:\dev\PlannedCRM/Employee\\config\app.yml
>> file+     C:\dev\PlannedCRM/Employee\\config\cache.yml
>> file+     C:\dev\PlannedCRM/Employee\\config\config.php
>> file+     C:\dev\PlannedCRM/Employee\\config\databases.yml
>> file+     C:\dev\PlannedCRM/Employee\\config\factories.yml
>> file+     C:\dev\PlannedCRM/Employee\\config\filters.yml
>> file+     C:\dev\PlannedCRM/Employee\\config\logging.yml
>> file+     C:\dev\PlannedCRM/Employee\\config\orm.yml
>> file+     C:\dev\PlannedCRM/Employee\\config\routing.yml
>> file+     C:\dev\PlannedCRM/Employee\\config\security.yml
>> file+     C:\dev\PlannedCRM/Employee\\config\settings.yml
>> file+     C:\dev\PlannedCRM/Employee\\config\tidy.conf
>> file+     C:\dev\PlannedCRM/Employee\\config\view.yml
>> dir+      C:\dev\PlannedCRM/Employee\\i18n
>> file+     C:\dev\PlannedCRM/Employee\\i18n\.sf
>> dir+      C:\dev\PlannedCRM/Employee\\i18n\global
>> file+     C:\dev\PlannedCRM/Employee\\i18n\global\.sf
>> dir+      C:\dev\PlannedCRM/Employee\\lib
>> file+     C:\dev\PlannedCRM/Employee\\lib\myAction.class.php
>> file+     C:\dev\PlannedCRM/Employee\\lib\myConsoleController.class.php
>> file+     C:\dev\PlannedCRM/Employee\\lib\myConsoleRequest.class.php
>> file+     C:\dev\PlannedCRM/Employee\\lib\myFrontWebController.class.php
>> file+     C:\dev\PlannedCRM/Employee\\lib\myUser.class.php
>> file+     C:\dev\PlannedCRM/Employee\\lib\myView.class.php
>> file+     C:\dev\PlannedCRM/Employee\\lib\myWebRequest.class.php
>> dir+      C:\dev\PlannedCRM/Employee\\modules
>> file+     C:\dev\PlannedCRM/Employee\\modules\.sf
>> dir+      C:\dev\PlannedCRM/Employee\\templates
>> file+     C:\dev\PlannedCRM/Employee\\templates\error.php
>> file+     C:\dev\PlannedCRM/Employee\\templates\error.txt
>> file+     C:\dev\PlannedCRM/Employee\\templates\layout.php
>> file+     C:\dev\PlannedCRM/web/index.php
>> file+     C:\dev\PlannedCRM/web/Employee_dev.php
>> tokens    C:\dev\PlannedCRM/web\\Employee_dev.php
>> tokens    C:\dev\PlannedCRM/web\\index.php
>> chmod 777 C:\dev\PlannedCRM/web/uploads\\assets
>> chmod 777 C:\dev\PlannedCRM\log
>> chmod 777 C:\dev\PlannedCRM\cache
>> chmod 666 C:\dev\PlannedCRM/web/uploads\\.sf
>> chmod 666 C:\dev\PlannedCRM/web/uploads\\assets\.sf
>> chmod 666 C:\dev\PlannedCRM/log\\.sf
>> dir+      C:\dev\PlannedCRM/test
>> dir+      C:\dev\PlannedCRM/test/Employee

Setup Apache2 VirtualHost

I've decided that I want a quick-to-get-to environment on my development machine, so I'm going to setup a VirtualHost pointing to my environment.

The XAMPP install creates a httpd.conf to support php, and optionally perl and python. This file is stored in `c:\xampp\php\httpd5.conf'.

I wanted to save the original file in c:\xampp\apache\conf\httpd.conf, so I renamed it to httpd.conf.original. First, copy the php\httpd5.conf to apache\conf\httpd.conf. Then open the httpd.conf in notepad and add the following to the bottom.

<Directory "c:/xampp/php/pear/data/symfony/web/sf">
  Allow from All
</Directory>

<VirtualHost *:80>
  DocumentRoot "c:/dev/PlannedCRM/PlannedCRM/web"
  DirectoryIndex index.php
  Alias /sf "c:/xampp/php/pear/data/symfony/web/sf"

  <Directory "c:/dev/PlannedCRM/PlannedCRM/web">
    AllowOverride All
    Order deny,allow
    Allow from all
  </Directory>
</VirtualHost>

NOTE: I figured this out after writing this -- And with some assistance from francois. The Alias path in the VirtualHost is very important if you want to see the effects of stylesheets. It needs to be pointed to the Symfony PEAR installation location.


Also, search for rewrite and enable the LoadModule for the mod_rewrite.

Also, I just realized that I want apache and mysql to run as services. So this will do that:

cd \xampp\apache
apache_installservice.bat
cd \xampp\mysql
mysql_installservice.bat

The cd into the directories is critical for the batch files to find the apps. Now, I just need to remember that to stop and start apache, I can use the commandline net stop apache2 and net start apache2.

Well, I checked to see if the symfony app would come up. -- NO, I get an Object Not Found error.

Oh, the path in the virtual host was c:/dev/PlannedCRM/PlannedCRM/web instead of c:/dev/PlannedCRM/web. A left over from a previous thought. After editting httpd.conf and restarting apache2, I tried again.

Different failure this time. -- more interesting also

Warning: preg_replace_callback() [function.preg-replace-callback]: 
Unable to call custom replacement function in 
C:\xampp\php\pear\symfony\symfony\config\sfCompileConfigHandler.class.php on line 112

Warning: preg_replace_callback() [function.preg-replace-callback]: 
Unable to call custom replacement function in 
C:\xampp\php\pear\symfony\symfony\config\sfCompileConfigHandler.class.php on line 112

Warning: preg_replace_callback() [function.preg-replace-callback]: 
Unable to call custom replacement function in 
C:\xampp\php\pear\symfony\symfony\config\sfCompileConfigHandler.class.php on line 112
[exception] sfInitializationException [message] 
Configuration file "C:\xampp\php\pear\data/symfony/config/php.yml" specifies that php.ini 
"magic_quotes_gpc" key must be set to "" [err0001] 
[code] N/A 
[class] sfPhpConfigHandler 
[file] C:\xampp\php\pear\symfony\symfony\config\sfPhpConfigHandler.class.php 
[line] 98 
[symfony] v. 1.0.0-DEV (symfony-project.com) 
[PHP] v. 5.0.5 [stack trace] at sfConfigCache::execute() in [C:\xampp\php\pear\symfony\symfony\config\sfConfigCache.class.php:66] 

at sfConfigCache::callHandler() in [C:\xampp\php\pear\symfony\symfony\config\sfConfigCache.class.php:150] 
at sfCompileConfigHandler::checkConfig() in [C:\xampp\php\pear\symfony\symfony\config\sfCompileConfigHandler.class.php:118] 
at sfCompileConfigHandler::insertConfig() in [C:\xampp\php\pear\symfony\symfony\config\sfCompileConfigHandler.class.php:95] 
at sfConfigCache::execute() in [C:\xampp\php\pear\symfony\symfony\config\sfConfigCache.class.php:66] 
at sfConfigCache::callHandler() in [C:\xampp\php\pear\symfony\symfony\config\sfConfigCache.class.php:150] 
at checkConfig() in [C:\xampp\php\pear\symfony\symfony\symfony.php:107] 
at require_once() in [C:\dev\PlannedCRM\Employee\config\config.php:47] at require_once() in [C:\dev\PlannedCRM\web\index.php:8] 

The browser kicked off this error. The key is up in the exception just after the 3rd warning. magic_quotes_qpc

I forgot to edit the php.ini to fix this and register_globals. So, notepad c:\xampp\php\php.ini and look for magic_quotes_qpc. Change it to Off, then search for register_globals and turn it to Off. Save the file and restart apache, since it only reads it on startup.

I thought that part of the problem that I was having might be the need to actually get a module built, so I decided to run an init-module

symfony init-module Employee Home

Gets me this:

C:\dev\PlannedCRM>symfony init-module Employee Home
>> dir+      C:\dev\PlannedCRM/Employee/modules/Home
>> dir+      C:\dev\PlannedCRM/Employee/modules/Home\\actions
>> file+     C:\dev\PlannedCRM/Employee/modu...Home\\actions\actions.class.php
>> dir+      C:\dev\PlannedCRM/Employee/modules/Home\\config
>> file+     C:\dev\PlannedCRM/Employee/modules/Home\\config\.sf
>> dir+      C:\dev\PlannedCRM/Employee/modules/Home\\lib
>> file+     C:\dev\PlannedCRM/Employee/modules/Home\\lib\.sf
>> dir+      C:\dev\PlannedCRM/Employee/modules/Home\\templates
>> file+     C:\dev\PlannedCRM/Employee/modu...ome\\templates\indexSuccess.php
>> dir+      C:\dev\PlannedCRM/Employee/modules/Home\\validate
>> file+     C:\dev\PlannedCRM/Employee/modules/Home\\validate\.sf
>> file+     C:\dev\PlannedCRM/test/Employee/HomeActionsTest.php
>> tokens    C:\dev\PlannedCRM/test/Employee\HomeActionsTest.php
>> tokens    C:\dev\PlannedCRM/Employee/modu...Home\\actions\actions.class.php
>> tokens    C:\dev\PlannedCRM/Employee/modu...ome\\templates\indexSuccess.php

Now opening a browser pointing at http://localhost gets the Congratulations page. Actually, I patched a file and reported a bug #39 before getting this working, but it works now.

Addendum:

Getting XdebugOnWindows to work is fairly straightforward, but slightly non-intuitive.