Bootstrapping Symphony
This is an open discussion with 1 reply, filed under General.
Search
Are there any best practices for bootstrapping Symphony?
You are doing it right! Before 2.6, it was a nightmare and I always ended up with
define('DOCROOT', str_replace(RELROOT, '', rtrim(dirname(__FILE__), '\/') )); require_once(DOCROOT . '/symphony/lib/boot/bundle.php'); require_once(DOCROOT . '/symphony/lib/core/class.cacheable.php'); require_once(DOCROOT . '/symphony/lib/core/class.symphony.php'); require_once(DOCROOT . '/symphony/lib/core/class.administration.php'); require_once(DOCROOT . '/symphony/lib/toolkit/class.general.php'); require_once(TOOLKIT . '/class.sectionmanager.php'); require_once(TOOLKIT . '/class.entrymanager.php');
Now requiring the autoload is enough :)
If you want your code to work with both 2.6 and earlier, you can check if the DOCROOT . '/vendor/autoload.php' file exists. If it does, require it, if not use the old code.
Create an account or sign in to comment.
I have a couple of cases in my project where I need to read or update Symphony Sections from standalone PHP scripts. Prior to v2.6 I was using the following code to bootstrap Symphony:
After upgrading to 2.6 I started seeing this error:
and had to insert the following line to fix it:
Everything seems to be working again but I'm wondering if there's a more robust way to do this. I just need to load enough of Symphony to use the EntryManager and FieldManager classes.
Are there any best practices for bootstrapping Symphony?