Symfony 1.1 Admin Generator Install Cookbook at Ubuntu

Monday, 28 July 2008 at 23:08 UTC 2 comments

Symfony is a full-stack framework, a library of cohesive classes written in PHP5.

It provides an architecture, components and tools for developers to build complex web applications faster. Choosing symfony allows you to release your applications earlier, host and scale them without problem, and maintain them over time with no surprise.
Symfony is based on experience. It does not reinvent the wheel: it uses most of the best practices of web development and integrates some great third-party libraries

1) install php-cli et al

* install necessary xsl transformator for PHP and php-cli

apt-get install php5-cli php5-xsl

* (optional) if you want to run the sf_sandbox example you the php sqlite extension:

apt-get install php5-sqlite

* depending on your planned database, install php mysql or postgres extension:

apt-get install php5-pgsql
apt-get install php5-mysql

2) install php pear – PHP Extension and Application Repository

from http://pear.php.net/ or under Ubuntu simple run

apt-get install php-pear

* upgrade pear to get most recent packages

sudo pear upgrade PEAR

3) install symfony with pear

see http://www.symfony-project.org/installation/1_1

* add symfony-project page to pear

sudo pear channel-discover pear.symfony-project.com

* install the latest release symfony 1.1

sudo pear install symfony/symfony-1.1.1

4) check if symfony is installed correct

symfony -V
symfony version 1.1.1 (/usr/share/php/symfony)

php -v
PHP 5.2.4-2ubuntu5.3 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 23 2008 06:44:49)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

5) apache config – add a virtual host

* pay attention to set the /sf alias, else your application will miss stylesheets (css etc.)
* to identify, which is your symfony/pear data directory

pear config-show

Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels auto_discover
Default Channel default_channel pear.php.net
HTTP Proxy Server Address http_proxy
PEAR server [DEPRECATED] master_server pear.php.net
Default Channel Mirror preferred_mirror pear.php.net
Remote Configuration File remote_config
PEAR executables directory bin_dir /usr/bin
PEAR documentation directory doc_dir /usr/share/php/docs
PHP extension directory ext_dir /usr/lib/php5/20060613+lfs
PEAR directory php_dir /usr/share/php
PEAR Installer cache directory cache_dir /tmp/pear/cache
PEAR configuration file cfg_dir /usr/share/php/cfg
directory
PEAR data directory data_dir /usr/share/php/data
PEAR Installer download download_dir /tmp/pear/download
directory
PHP CLI/CGI binary php_bin /usr/bin/php
php.ini location php_ini
PEAR Installer temp directory temp_dir /tmp/pear/temp
PEAR test directory test_dir /usr/share/php/tests
PEAR www files directory www_dir /usr/share/php/www
Cache TimeToLive cache_ttl 3600
Preferred Package State preferred_state stable
Unix file mask umask 22
Debug Log Level verbose 1
PEAR password (for password
maintainers)
Signature Handling Program sig_bin /usr/bin/gpg
Signature Key Directory sig_keydir /usr/etc/pearkeys
Signature Key Id sig_keyid
Package Signature Type sig_type gpg
PEAR username (for username
maintainers)
User Configuration File Filename /home/thomas/.pearrc
System Configuration File Filename /usr/etc/pear.conf

cat /etc/apache2/sites-enabled/admintool

ServerAlias admintool

DocumentRoot /web
Alias /sf /usr/share/php/data/symfony/web/sf

apachectl graceful

6) unix group settings

* add user e.g. myuser to group www-data
* i needed this in my first sf_sandbox installation from scratch
/etc/group

* as i installed a new project and application with symfony this was no longer necessary

7) add a local name for apache

important, use 127.0.0.1 or add to your frontend_dev.php or appname_dev.php your different local IP
(symfony restricts to local access for all development files
)

/etc/hosts
127.0.0.1 localhost admintool

8) (optional) found a bug in original symfony sandbox archive

* this is only relevant for sandbox examples testing with sqlite
* aou need to modify config/propel.ini

propel.database.createUrl = sqlite://./../../../../data/sandbox.db
propel.database.url = sqlite://./../../../../data/sandbox.db

9) create the symfony project

mkdir admintool
cd admintool
symfony init-project admin

10) create the symfony application

symfony init-app adm

11) configure postgres database

config/database.yml

all:
propel:
class: sfPropelDatabase
param:
phptype: pgsql
host: localhost
database: DBNAME
username: DBUSER
password: DBPASSWORD

12) describe database schema model

*IMPORTANT! use spaces only, never use tabs, pay attention of similar ident

config/schema.yml

propel:
article:
id: ~
email: varchar(255)
created: timestamp
locale: varchar(255)
login: varchar(255)
password: varchar(255)
status: integer
product:
id: ~
comment: varchar(255)
created: timestamp
state: integer
title: varchar(255)

13) (optional) create sql and insert to an empty database

* if want to create a local database and filling test data

symfony propel:build-sql
symfony propel:insert-sql
php batch/load_data.php

14) building the model from given schema.yml definition

symfony propel:build-model

15) generate the application based on generated model classes

* one for each table

symfony propel:init-admin adm article Article
symfony propel:init-admin adm product Product

16) test the first application

* http://admintool/adm_dev.php/product

If you make any modifications on the model or add plugin etc. run clear-cache task (cc)

symfony propel:clear-cache

Other Resources:

* The Symfony Framework Homepage
* Symfony 1.0 Tutorial Extending Admin Generator from Par COil at strangebuzz (April 2008)
* A Symfony Beginner’s Tutorial from Francois Zaninotto at sitepoint (April 2007)

Advertisements

Entry filed under: programming. Tags: , .

SpringSource Announces General Availability of SpringSource Enterprise Securing php with mod_security

2 Comments Add your own

  • 1. jez  |  Thursday, 7 August 2008 at 11:39 UTC

    Although an ok step by step guide, i am a bit disappointed in this page as it was referred to by a post you made to a symfony forum with a specific problem in the init-admin step, yet just like the symfony documentation you have only described how it is when everything works.

    Please update this to show how you fixed a

    Unable to scaffold nonexistent model

    error in the admin-init???

    The only failing of the extensive symfony docs is troubleshooting, specially when you are often doing things new to a web programmer e.g. building code, such as admin-init.

    Aside from that, symfony is ok, i dont think am as blown away as most by it. Maybe i am not seeing the speed of development as i am chasing poorly documented exceptions.

    Reply
  • 2. moojix  |  Thursday, 7 August 2008 at 12:45 UTC

    on my first day on admin-generator i got with admin-init the following error message:

    Unable to scaffold nonexistent model “Post”.

    i forgot to update model classes after modification of the initial model. the solution was simply run:

    symfony cc
    symfony propel:build-model

    http://www.symfony-project.org/forum/index.php/m/57193/#msg_57193

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories


%d bloggers like this: