Category Archives: Setup
I love pretty URLs. I don’t like file name extensions unless they end with .html.
All versions of symfony save me from address bar ugliness, but only for the first application I create. Everything else is ass.php/backwards.
I’m going to give you two ways of beautifying your second, third, and forth applications so you can http://www.get.your/application/looking/sexy. Both methods involve creating a subdirectory.
Put it all in a subdirectory, and symlink your way out
So if you have an app named “admin,” you can do the following:
- Create a directory in your web folder called admin
- Copy your admin.php and admin_dev.php into this folder
- Copy the .htaccess file into this folder
- Rename admin.php to index.php
- Edit the file now named index.php, and change the require_once statement at the top so it’s an extra directory back
- Symbolically link the js, css, images, and uploads directories from within the admin directory to the directory above; so from your app directory:
ln -s ../js
This is what I usually do in a Linux environment. However, I’m developing on a Windows box, and symbolic links don’t translate easily between Windows and Linux. So here’s the second option, without using symbolic links:
Put just the .htaccess in a subdirectory
- As before, create a subdirectory in your web folder for the admin.
- Copy the .htaccess file in, and at the very bottom of the file, change index.php to ../admin.php. It should read
RewriteRule ^(.*)$ ../admin.php [QSA,L]
- Edit your routing.yml file for the admin app, and append /admin/ to all of your routes.
That should about cover it. Also remember to set no_script_name to on in each of your applications.
Alternative methods? Please leave comments.
While using Eclipse PDT, every time I tried to open a YAML file, the software would try to open the file externally. Since I had no YAML editor installed, this would generate an error.
Now I could right click and choose Open With –> Text Editor. But I wanted something a little better than a simple text editor, and I didn’t want the extra clicks.
That’s where Yedit came in, another great plugin for Eclipse. The plugin can be found here:
It installs easily in Eclipse:
Help –> Software Updates –> Add Site
Select the plugin from the list under this site, and click Install…
Remember to restart Eclipse after you install, in order to see the update. You should now be able to open YAML files in your project easily.
It slows your application down a lot.
I am running Symfony 1.2 in a Windows Vista environment.
If I package the Symfony libraries with my application in the lib/vendor directory, as described in Day 1 of the Jobeet tutorial, there is a significant slowdown in performance (approximately 20 seconds on my recently purchased Dell XPS laptop).
This slowdown happens on the first load of the project inside the web browser, and on the execution of every Symfony shell task.
However, if I use a PEAR distribution of Symfony, this slowdown pretty much goes away entirely.
Here is the difference, depending on which autoloader I place in my config/ProjectConfiguration.php file:
about 2 or 3 seconds
about 20-22 seconds
I will update this post if I find the reason for this. In the meantime if you’re developing in Windows, stick to using the PEAR copy.
For more information on this phenomenon, please check out this thread on the Symfony forum.
I tried switching the project over to the PEAR libraries, and there was no change in speed. I have two projects on the same machine, running off the same libraries, but one is much faster than the other. I still haven’t figured out what the difference between the two might be.
This may be the final update. The slow project was created with Symfony 1.2.7. The Symfony installed from PEAR was 1.2.5. When I wiped the project generated from 1.2.7 and regenerated with version 1.2.5, the speed jumped up again.
So is there a lesson in all of this? For now, it’s to use version 1.2.5 installed with PEAR, and not 1.2.7 packaged with the project. I’ll have to leave it at that for now.