Symfony

From A2Wiki

Jump to: navigation, search

Contents

How To Install Your Symfony App on A2Hosting

A2 has great support for symfony sites. At the time of this writing, most servers have the PEAR installation of Symfony 1.0.x or Symfony 1.1.x already loaded (if not you can request it).

These steps also assume you have SSH access to your account, which is highly recommended if you intend to build a site in Symfony. Note: this is not required as FTP access will suffice, albeit abit more difficult to configure. Check out the Symfony Wiki for more information.

After logging in to your account via SSH you can check your installed Symfony version by typing

# symfony -V

(Note this is a capital V, not lower case v)

1. To begin, upload your entire project to your home directory. You can do this easily using the symfony "sync" command. In order to use this command, you must first set up the ssh information used to access your hosting account. Find this file in [myproject]/config/properties.ini. Full instructions can be found in the deployment chapter of the Symfony documentation. Here is what a sample properties.ini file looks like:

[symfony]
  name=myproject

	[production]
	  host=[domain name]
	  port=7822
	  user=[username]
	  dir=/home/[username]/myproject

Notice we specify port 7822 to accommodate the SSH port used by A2.

2. Make sure to change permissions on the cache and log folders in your new project folder on the server.

/home/[username]/myproject$ symfony fix-perms

3. Now you are faced with a decision. If you want to host your site at the root of your domain, you will want to make your "myproject/web" directory your new public_html folder.

  • Move the ~/public_html directory to a backup:
cp ~/public_html ~/public_html.bkp
  • Create a new symlink that points ~/public_html to your symfony app's web directory
ln -s ~/myproject/web/ ~/public_html

4. If you want to host your site in a folder on your domain, like www.mydomain.com/myproject, you can make the symlink within your public_html folder:

ln -s ~/myproject/web/ ~/public_html/myproject

Most of a2's servers have a global Alias configured to route "/sf" to the symfony sf directory on the server. If this isn't set up on your host, you can add another symlink like this:

ln -s /usr/lib/php/data/symfony/web/sf ~/myproject/web/sf

Note: for some versions the path is /usr/local/lib/php/symfony

If your Symfony site is in a folder on your domain, the folder name will be prepended to /sf so will not be found. For example, if your Symfony site is ~/public_html/myproject, links to the /sf folder will be generated as /myproject/sf

You can get around this by adding a redirect rule to the .htaccess file in the project folder. In ~/public_html/myproject/.htaccess, add the following lines after the "#Rewrite Base /" or "Rewrite Base /" line

#Rewrite Base /

#Redirect for sf folders
RewriteRule sf/(.*)$ /sf/$1 [L]


How to host multiple projects under subdomains

I generally will upload my symfony projects to a staging area while I am working on them so I can show clients progress.

1. Create the subdomain using cPanel. If I set up the subdomain "app1.mydomain.com", it will generally point to a new directory in my public_html folder with the same name (app1).

2. Upload symfony project to my root directory (NOT public_html, but the level above that). In this example the path is:

/home/[myusername]/app1

3. Now, I need to point the folder created by the subdomain in step 1 to my new project's web folder uploaded in step 2:

# cd ~/public_html
# rm -rf app1                //remove the original directory created by subdomain
# ln -s /home/[myusername]/app1/web app1   //make a symlink to my projects web directory

4. You're done!


How to Override the location of the default "/sf" directory

If you want to set up another location for symfony to look for its built-in web files, typically found in the path "/sf" on your site, you can edit these settings in your application settings, found in [myproject]/apps/[myapp]/config/settings.yml.

production:
  .settings:
    prototype_web_dir:      /sf_v1/prototype
    admin_web_dir:          /sf_v1/sf_admin
    web_debug_web_dir:      /sf_v1/sf_web_debug


How to install the latest version of Symfony through SVN

You can check out a copy of that latest (BETA!) version of Symfony right into your hosting account. This is useful if you want to upload your symfony project that you have been developing locally. 1. SSH into your home directory

 ssh yourdomain.com -p7822

2. make a new folder in your home directory and check out the latest source code.

mkdir ~/mysymfony
cd ~/mysymfony
svn co http://svn.symfony-project.com/tags/RELEASE_1_2_7/ .

3. Now that the symfony library is installed in your directory, you can upload your Symfony v1.0 projects without having to "freeze" them first (more on this in the documentation). Just upload your project as your would normally, and then update the settings in [myproject]/config/config.php to point to the new location of the libraries:

<?php

// symfony directories
$sf_symfony_lib_dir  = '/home/[username]/mysymfony/lib';
$sf_symfony_data_dir = '/home/[username]/mysymfony/data';

Once you do that you will probably want to tell your project not to overwrite the config.php everytime you sync up. Edit rsync_exclude.txt in the [myproject]/config/ directory:

stats
.svn
.htaccess
.DS_Store
web/uploads
cache
log
config/config.php

All done! Your new shiny symfony project is online and it even knows where to find all of it's required files. You can upload other projects to your account and have them all share this common library (see more about uploading multiple projects to subdomains above).


for Symfony 1.1:

just change your project configuration file to point to your installation:

also...i had to ad a symlink:

ln -s ~/mysymfony/1.1/data/web/sf ~/myproject/web/sf 

so that my symfony images showed up and scripts loaded

Internet Explorer tries downloading a file instead of showing it in the browser

This was reported by one of our users and is caused by an error in

app/{app-name}/config/view.yml

Adding

"content-type: application/xhtml+xml"

Should fix this problem! Stereo 16:42, 11 December 2006 (EST)


Solving IonCube or PHP Memory Problems

If you encounter either of the following errors running Symfony or PEAR from the command line:

  • Failed loading /usr/local/IonCube/ioncube_loader_lin_5.2.so: /usr/local/IonCube/ioncube_loader_lin_5.2.so: cannot open shared object file: No such file or directory
  • Fatal error: Out of memory (allocated xxx) (tried to allocate xxx bytes)

First, check your code for any memory_limit settings (results shown are a sample; yours may be quite different):

cd ~/path/to/symfony/root
grep --recursive memory_limit *
lib/symfony/vendor/phing/Phing.php: // $mem_limit = (int) ini_get('memory_limit');
lib/symfony/vendor/phing/Phing.php: ini_set('memory_limit', '16M'); // note: this may need to be higher for many projects
memtest.php:
plugins/steerCMSFoundationPlugin/web/index.php:ini_set("memory_limit","16M");
plugins/steerCMSFoundationPlugin/web/cms/index.php:ini_set("memory_limit","16M");
plugins/steerCMSFoundationPlugin/web/frontend_dev.php:ini_set("memory_limit","16M");
web/index.php:ini_set("memory_limit","16M");
web/cms/index.php:ini_set("memory_limit","16M");
web/frontend_dev.php:ini_set("memory_limit","16M");

If you see any entries, remove them or comment out and try your actions again.

If that still doesn't work, open a support ticket at https://support.a2hosting.com asking for your username to be added to the 'mongrel' group, and for your shell to be set to bash. This will bypass ioncube and give php a memory_limit of 128M.


Uploading from Windows - ProjectConfiguration.php

You have to change your ProjectConfiguration.php so it points to the sfCoreAutoload class.

Which (on my server anyways)...was located at : /usr/local/lib/php/symfony/autoload/sfCoreAutoload.class.php

you can check your locations via SSH by simply going "cd /usr/local"....(for newbies like me)

Personal tools