Learning progaming with symfony is a evolutional process (for me). So, I have to do things new I have done, or I have to change them.
Now I have changed the structure of the project. It lives not longer complete in the web directory, it lives now in my user and only a symbolic link 'projectname'-> 'User/.../procektname/web' is in the web directory.
Before this Change, I have to start the app in the browser with http://localhost/dev_app.php/, now it is http:localhost/project/dev_app.php. It runs fine. And I think, so I can run more than one Symfony project on one computer.
But when I start the config.php and go through the configuration (database and secret) the config.php will write the config data to the old path. Why? Is there anything to do after moving the project?
P.S. I think its harder than I wrote. You must know, that I have not moved my project, I have made a copy and moved the copy. A view minutes ago, I have done following: Changing the name of the original. And now nothing runs!
php app/console cache:clear --env=prod --no-debug
ends with a RuntimeExeption, and I can see, it will clear the cache at the old path!
I delete the cache by hand and the App runs. At least there is the question why I get the Exeption when I clear the cash with the console. But I think it is another problem.
I had exactly the same problem than carp-enter.
And Wouter J posted exactly the right symfony link.
We need to override getters for paths.
After, it works very fine.
Related
I am new in Symfony2 and I am working in a project in the prod environment.
I changed a twig file so it looks like I have to clean the cache to update the page.
There is any risk at cleaning the cache of the project?
It is possible that I am going to lost any important file?
If yes, there is a way to make this update of some safer way?
Short answer: yes, it can be dangerous. No, there's no safer way. You should take a backup of the whole application root (cache included).
Details
The cache folder contains "compiled" files. Unless someone is doing something very wrong, it does not contains important files. And - even if it does - it would probably be quite complex to get them out from cache.
So at first glance you should be able to delete the cache anytime you want without fear.
Cache version
There's a small catch: you cannot be sure that - even before your changes - the current cache is sync with the current source code.
If, previously, someone made changes to the application but did not clear the cache, those changes are not actually used in production.
In this case, when you clear the cache all such changes will be released as well as your change.
Suggestion
Right now the only way is forward, so you have to clear the cache. But you may want to:
backup first
get a list of more recent changes to source code
do the task when you have time to test and fix if something comes up
In the long term, you should use a deploy script / system to make sure that the cache is automatically cleared any time some changes to source code is delivered.
To deploy a meteor app, you enter meteor deploy my_first_meteor_app.meteor.com
To update the deployment, is there a faster way than typing the above command again? It's quite tedious if you have a long domain name like the one in this example.
Yes. You can user aliases (nothing to do with Meteor). This is how you do it on a Mac:
alias new_name='command to be performed'
After which you must store the changes permanently in the file:
~/.bash_profile
See a full explanation here: http://www.maclife.com/article/columns/terminal_101_creating_aliases_commands
Also, you can try running meteor deploy without the site name. I don't remember if that works or not though. meteor deploy does remember old settings files that were used, but I'm not sure if it remembers the site name you used too.
I searched and tried a couple of tutorials on the internet but none of them worked for me well.
The tutorials I followed were from Symfony2 documentation, Dator, Hpatoio and Capifony.
Can somebody explain to me how I can export my project into my server. E.g. www.domain.com/about.
It would be very helpful to me.
I have a bundle and inside the bundles all controller and twig templates etc are set.
If you have any questions please ask.
Thanks in advance.
First off it should be noted that deploying a Symfony2 app over FTP is really really bad. It makes a couple of steps more difficult (or even impossible) and should be avoided. If you have SSH access to the machine look at my list of alternative deployment methods below.
Preparation
There are a few things you cannot influence when you deploy over FTP. If you have no control over the following or can not configure them correctly you unfortunately have no chance of deploying to a shared hosting.
The PHP configuration. If settings are not set correctly and you have no chance of changing them you are unfortunately lost.
Any PHP module you may require. Same as above. If you can not install any additional modules you need there is no chance for you. (An example for that would be the php5-intl module for any Symfony <2.6)
Correct folder permissions. Especially for app/cache and app/logs. Check the docs for requirements.
The Webserver configuration. Symfony needs a correctly configured Webserver (in most cases probably apache or nginx) to function correctly. If you can not influence the config this is bad as well. You might want to try to define the rewrite rules in a .htaccess file as described here.
Deployment
Here are the steps you need to follow to prepare your application for deployment for the first time:
Update / Install vendors. Use composer install (or composer update) to install any third party bundle or library you use in your project since you have no option to install them later directly on the server.
If you use Assetic for your asset management, make sure you install these as well with the php app/console assetic:dump --env=prod command.
Dump any other assets like so: php app/console assets:install --env=prod. (This step might not be required but you need to make sure the assets are not symlinked. Check this blog post if you are using symfony >=2.6)
Clear the cache for production: php app/console cache:clear --env=prod
Make sure you edit your parameters.yml to fit the needs of your production server.
Also update your database schema on your production database in case you have changed it during development.
Now you should be good to go. Copy the whole folder onto your server and try it out.
For the future
If you deploy for the second time make sure not to override any user data (e.g. uploaded images). Also you need to clear the cache over ftp. To do that empty the app/cache directory.
Alternative deployment methods
In case you have more access to the server check out any of these. They might fit your needs better than old pure FTP. Maybe they give you reason enough to change to a more appropriate server. Capifony is probably one of the best deployment tools for Symfony2 apps. Deployment will be as easy as running cap deploy on your local machine. The rest is magic ;) Simple git is also possible for deployment. Many of the above steps will still apply but you have all the advantages git gives you like not copying everything every time you deploy. A very good list of all tools can be found in the docs.
It might help if you tell us a little more about your server set up, but here's a fairly generic guide:
Assuming you want to upload it using ftp (since you tagged the question as such), you will need an FTP
client (see here for some suggestions).
Using the FTP client, you'll want to connect to your server
(hostname: yoursite.com) using your credentials (if it is a secured
server).
From there, you should be able to upload any files from your local
machine to the server.
More specific directions will depend on your server configuration and the FTP client you choose (it should come with its own manual)
On production we use amazon opsworks to orchestrate our machines. I've created a chef recipe to deploy new code (so actually creating a new release folder, do things there, then switch symlink to new folder) and another recipe that reconfigures our symfony app changing a yml file when a new database slave is added and so on.
The problem is that the reconfigure stage happens on current running code and since I've to run cache:clear and cache:warmup the requests in the meanwhile fails since they don't find cache files/folders.
How could I clear the cache instantly? Maybe warming it up in another folder and then switching those?
Better solutions?
Found by myself that cache:clear (without --no-warmup) actually does the warmup in another folder and exchanges them on finish.
The reason I wasn't using that was due some library issues on warmup when not using --no-warmup && cache:warmup which seems to be solved now.
Let's see how things works after this change and if I don't get these problems anymore
UPDATE:
I did some tests of firing up new machines, running cache:clear under heavy request load and no php warnings/errors so far.
I think this is a definitive solution for my problem
I never know what to do when my Wordpress installation tells me there's an update available. I am using version 2.8 so whenever there is an update, all I have to do is click update, some magic happens behind the scenes, and it gets updated. But should I create backup files? And how? I have custom themes and plugins that I don't want to get lost because I don't have backups! Is it safe to assume that nothing bad will happen when you click the upgrade button? What is your process when you decide to upgrade to the newest version?
Backup the database, wp-content directory and configuration files first.
There are plug-ins to make this easier, but since you're asking on StackOverflow, I'll assume you could write a script to do it yourself. While you're at it, add the script as a cron job.
http://codex.wordpress.org/WordPress_Backups#Backup_Resources
Always backup before making a big change like that.
You'll want to copy all your files to a safe place via FTP. Copy 'em, zip 'em up, and keep them somewhere safe where you can remember where they are. You'll also want to backup or "export" the database and keep that also safe. This way if something goes wrong, you can restore it to the way it was.
There's a good backup script here for Wordpress sites:
http://www.guyrutenberg.com/2008/05/07/wordpress-backup-script/
based on Bash and bzip2.
I usually don't update nothing in production without testing it first, unless is a simple modification and is about security (like the 2.8.4 update).
The ideal thing to do is create a separate installation to be a test server: can be in your local machine, or just a whole different installation in your server. Why? Remember you have plugins installed and some may break, updating everything can't be a "blind" decision!
So, before updating in the production installation/server, always test in the "test environment".
Nothing is worse than having your website down because of an update error.