| Version 13 (modified by anonymous, 7 years ago) |
|---|
symfony FAQ
Problem installating symfony
If you have problem installating symfony or cannot launch the symfony command line program, check you have zend.ze1_compatibility_mode set to Off in your php.ini.
Memory problem when installing symfony via PEAR
pear install symfony/symfony Fatal error: Allowed memory size of XXXXXX bytes exhausted (tried to allocate 39 bytes) in /usr/share/php/PEAR/XMLParser.php on line 133 Allowed memory size of XXXXXX bytes exhausted (tried to allocate 23 bytes)
If you have this error message, you must increase the memory_limit in php.ini. An other solution I found to this problem, which does not require to edit php.ini is: PHP_PEAR_PHP_BIN='/usr/bin/php5 -d memory_limit=32M export PHP_PEAR_PHP_BIN
How do I use SQLite with symfony?
Note that Symfony versions up to and including 0.4.4 (and possibly higher) do not support SQLite v3.x, yet. Use v2.x and lower for now.
To use a SQLite backend, you need to change your orm.yml configuration file (in application config directory):
all: adapter: sqlite database: /path/to/yourproject/data/db.sqlite
and also change your propel.ini (in project config directory) to be able to generate sql schema file:
propel.database = sqlite propel.database.url = /path/to/yourproject/data/db.sqlite
Now, you can create the model, ...
symfony build-model
... generate the SQL schema, ...
symfony build-sql
... and populate the database.
cd /path/to/yourproject sqlite data/yourproject.db < data/sql/schema.sql
You *will* see errors on the first population of the database, looking like this:
drop table users; SQL error: no such table: users drop table groups; SQL error: no such table: groups drop table articles; SQL error: no such table: articles drop table comments; SQL error: no such table: comments
This is caused by the DROP TABLE statements schema.sql contains. As there are no tables in an empty database, none can be dropped, and this results in an error.
Now clean the symfony cache...
symfony cc
... and test your website with the shiny new SQLite backend.
So, what about the other way around. Like, when you already have your SQLite database and need to generate a schema of it?
That, of course, can be done using the propel/creole backend of symfony, too. Unfortunately it's not really documented (or I missed it) how a sqlite DSN is expected to look like. But I found out anyway. And one could say it looks a bit weird:
This is what you need to set in /path/to/yourproject/config/propel.ini if your sqlite databse is located at /path/to/yourproject/data/yourproject.db :
propel.targetPackage = model propel.project = yourproject propel.database = sqlite propel.database.url = sqlite://localhost//path/to/yourproject/data/yourproject.db propel.output.dir = /path/to/yourproject
After that, you can create the schema:
cd /path/to/yourproject symfony build-schema
which will then be available at /path/to/yourproject/config/schema.xml
How do I retrieve a creole connection?
$con = Propel::getConnection();
I can't see pages that require access to a database
If pages that require connection to a database produces the following error:
!PropelException: No connection params set::
Be sure that the database name in your schema.xml is set to 'symfony'
(http://www.symfony-project.com/content/book/page/model.html Symfony model - XML Data Model])
My YAML configuration file doesn't work
YAML files can be wrongly interpreted if the values contain special characters (such as slashes, colons, etc.). To avoid errors, enclose the value in single quotes, by changing:
namespace: key: that's an incorrect value ! 100% chance to cause an error
to:
namespace: key: 'that''s an incorrect value ! 100% chance to cause an error'
In addition, tabulations are forbidden in YAML files. Always use double spaces instead of tabulation.
Check more about the YAML syntax here.
The symfony command produces strange errors when processing the schema.xml file
Check that in the project's config directory are no other .xml files. The propel generator invoked from the symfony command processes all files ending in schema.xml files, not only the schema.xml file it should.