Symfony 2.2 Deployment Questions - symfony

Because of an other problem on my server, I tried to setup a real new project and did this (localhost with xampp on windows):
installed curl
loader composer like told in docs
loader vendors like told in docs
merged app/config-folder
copied src-folder
copied web/bundles/myBundle-folder
After that, I tried the deployment-steps documentation. I skipped uploading the files and editing parameter.yml (it's already configured for localhost).
Than I am running into trouble doing 'B) Update your vendors':
php composer.phar install --optimize-autoloader
This steps remove all my files from the web\bundles\myBundle-folder.
Do I have to tell composer about my bundle? I first thought, that I have to store them somewhere else, but this thread tells me, that I am right?!

The thread you are mentioning is from symfony 1, but you are installing a symfony 2 application.
In web/bundles are your assets installed (css, javascript and images).
Your bundles which will be installed via composer are in your vendors folder.
And your own bundles should be in the src folder.
I think this is a good start to have a look at where to store your files.
Your css, js and images should be stored in a bundle, e.g.:
src/AcmeDemoBundle/Resources/public/css
src/AcmeDemoBundle/Resources/public/js
src/AcmeDemoBundle/Resources/public/images
And then you can install your assets with php app/console assets:install web and they will be pushed into the web/bundles folder.

Related

Symfony 4 - Assets folder not found

According to Symfony Best Practices,
Store your assets in the assets/ directory at the root of your project.
But currently, I don't have this folder created and if I create it, I got the error telling me that ressources can't be found.
I tried composer require webassets , but don't working.
Anyone have the solution ?
Regards
Placing assets folder in root directory is best practice. Reason that root directory cannot be accessible from outside. You should try Symfony's Webpack Encore plugin. It compiles your minimized and compressed assets into public folder so they can never be shown as original.
If that is not fit your interest just put your whole assets folder into public directory.
You try following command.
$ composer require encore
$ yarn install
May be good to refer to here.
http://symfony.com/doc/current/frontend/encore/installation.html
Enable the encore composer require encore
update yarn yarn install

Capistrano deployment with Symfony 2 and Vagrant

So I have a cap file linked to my github and setup to deploy my project to my server. When I run
bundle exec cap prod deploy it all works without a hitch.
I can see my code being cloned from my repo, a new release folder is created and symlinked to the current folder. However any changes I've made to my code aren't reflected.
The repo being cloned is a fork of the original repo which I created when I began working on the project. I haven't made any changes to code base except adding a single line to a twig file.
I have updated the deploy.rb so that it pulls from my forked repo instead of the original one and can see the code change in my latest commit. However the change is not reflected on the site.
Any ideas why this might be happening?
Cheers
Two possibilities come to mind other than using the incorrect URL to the forked git repository -
I occasionally try to deploy a new copy of my own site, but I have not yet pushed the latest code from my development server (and the local repo) to the live repo on Github, but it is from Github that the code is being fetched from during deployment.
As a final step, Capistrano changes the location that the 'current' symlink points to the newly deployed directory in the 'releases' directory. Your webserver (apache or Nginx must be set to use the 'current' symlink) as part of the base directory (it will probably be ..../current/web/, and then auto-load app.php from that directory, unless there a subdirectory/file exists, for .CSS/JS/images/etc). If the webserver config refers to the 'release' directory, and not the symlink, it will only be a specific, older, deployment.

setting symfony for local development on herkou

I am trying to set up my symfony 2.8 app for local development.(Following - https://symfony.com/doc/current/deployment/heroku.html)
Added In proc file
web: bin/heroku-php-apache2 web/
Error
bin/sh: vendor/bin/heroku-php-apache2: No such file or directory
Also note , composer.phar config bin-dir is bin
Anyone who can share how they resolved this problem?
First of all, have you tried letting heroku create the Procfile itself? I think lately it was smart enough to work out the root of the Symfony project.
If that doesn't work, maybe that's not the right path, try:
echo 'web: $(composer config bin-dir)/heroku-php-apache2 web/' > Procfile
If none of those work, I'd rather use the heroku information on how to deploy your Symfony app, have a look at this and see if it helps:
https://devcenter.heroku.com/articles/getting-started-with-symfony

Autoload Bundle with custom path in Symfony2

I am developing a Symfony2 web app that will be hosted on an Ubuntu server and want my directory structure to be:
/Symfony (with an app,bin and vendor folder in it)
/Site1
/Site2
This way site1 and site2 use the same Symfony framework. In /Site1 I want:
/web
and in there I want app.php and app_dev.php as well as /web/AppBundle with all of the bundle files. I already figured out that I need to change in app.php require_once DIR.'/../Symfony/app/AppKernel.php'; in 2 places as per http://symfony.com/doc/current/cookbook/configuration/override_dir_structure.html
When I generated the bundle I did get the message "Checking that the bundle is autoloaded: FAILED" and that I should "Edit the composer.json file and register the bundle namespace in the "autoload" section"
I added "AppBundle": "/web/AppBundle" to the composer.json autoload section and in cygwin I run "composer -n install" It starts with saying that it is loading composer repositories and then it says "Installing dependencies (including require-dev)" and never goes past that.
What can I do to register this bundle that is not in the standard folder so that autoload picks it up? I am just getting the fact that the class could not be found in AppKernel.php
Thanks.
It's simple. Just don't do it! Use symfony as it is intended with its default directory structure.
Great two projects. If you have common code, extract it to an extra bundle and install it in both projects via composer.

Symfony caches Twig templates in web folder

I had a clean Symfony 2.7.3 installation (now updated to 2.7.4). In the app/cache/ folder, the normal cache files for prod and dev are written, but in the /web/ folder there is a folder named 1 with several files in it (web/1/3/7/37f3b66c84cbaf22abc4c5939452d2181eff0b0ec427c68c5499e3743849be17.php for example).
They are cached Twig templates, but why are they stored there? How to get them into the common cache folder?
I use Windows with Xampp 1.8.2, but on several Linux servers it's the same, so it should not be a server or PHP problem. Hope anyone can tell me what's wrong.
Look at your twig config in config.yml and search for cache:
twig:
cache: "%kernel.cache_dir%/twig"

Resources