PhpStorm doesn't see translations when moved to app/Resources - symfony

I had some translations in my bundles, for example in src/Bundle/AppBundle/Resources/translations but when I moved it to app/Resources/AppBundle/translations in my Twig templates it shows that translations are missing. I've tried invalidating cache and restarting the IDE but it didn't help.
How can I fix this?
My PhpStorm version: 2017.2.1.

Symfony Documentation:
"Each time you create a new translation resource (or install a bundle that includes a translation resource), be sure to clear your cache so that Symfony can discover the new translation resources"
Phpstorm may be processing by reading the cache files.
Try clearing the Symfony cache.
bin/console cache:clear
Optimize Composer.
composer install --optimize-autoloader

this issue is fixed in PhpStorm Symfony Plugin via https://github.com/Haehnchen/idea-php-symfony2-plugin/issues/1010

Related

Symfony deployment problem on hostinger, impossible to download dependencies

I have been trying for several days to deploy a Symfony site. All the files are well in the public folder with the .htaccess, I only need the dependencies for the site to be functional. The problem is that when I run the command
php composer.phar update
I get several error messages concerning my version of PHP.
The host is hostinger. I know the problem comes from the composer.json file and the version of the bundles but I don't know how to solve the problem.
Thanks
you need php version 8.1 as the message says. Normally, for a deployment you should not launch a composer update. It would rather be a composer install.
I contacted hostinger, and the problem is that the server was in PHP7 after changing to PHP8 it worked. Thank you all for your responses

impossible to generate bundle

i'm new to the symfony framework and i'm trying to generate my first bundle ,
i use this command php bin/console generate:bundle but it's not working.
The error message :
There are no commands defined in the "generate" namespace.
You may be looking for a command provided by the SensioGeneratorBundle which is currently not installed.
Try running composer require sensio/generator-bundle.
https://imgur.com/csryfHZ
I've tried to install composer repositories with the command composer require sensio/generator-bundle and nothing has changed
In symfony 4, this bundle is deprecated, you must use the maker-bundle, unfortunately there is no bundle generator available. So you'll need to code your bundle from scratch with the official documentation: https://symfony.com/doc/current/bundles/best_practices.html
By the way, bundle are deprecated and are now only use to share packaged code between projects.
More informations at: https://symfony.com/doc/current/bundles.html
We're not making bundle in Symfony 4.
While it was "good practice" withg Symfony 2, since the new skeleton, it's not the case anymore.
Your default bundle is now App, all your code goes in src/, and all your view (twig files) goes in template/

Composer misses to install certain files (app/console, AutoLoader.php, app_dev.php, etc.)

I am developing a web application with Symfony 2. The code of my own bundle that forms the heart of my application and some configurations files for application-wide settings are controlled by Git (mostly the directories, src/MyCompany/MyBundle, app/Resources/config, etc.) The rest is under control of Composer (the framework, 3rd party bundles, etc.)
Up to now, I ran a ./composer self-update && ./composer.phar update once in a while, pushed or fetched source code from the origin of my repository and everything has been working well.
Today, I started a new fresh working directory and experienced some odd problems.
I performed
git clone <my git repo url> www
cd www
composer.phar install
The composer.json is part of my repository, hence it normally suffices to excute Composer in order to install the framework and all required bundles to get a fully working copy of my web application.
But today, composer.phar install stopped prematurely complainig about missing files. Luckily, I still had my old working directory, so I could copy over the missing files manually, and restart composer.phar. I had to repeat these steps several times until I ended with a fully working application.
The files that were missing are
app/console
AutoLoader.php
app_dev.php
AppCache.php
I thought that these files are part of the Symfony framework and expected them to be installed by Composer. Fot this reason they are not under control of my revision control system.
I found this related question. The answer is very generic und not particularly helpful. All it says is that for example app/console should be included into revision control, because it is not installed by Composer (any longer) and that there is a change in the directory structure due to the transition from Symfony 2 to 3. But I know for sure that app/console was installed by Composer in the past. Hence, something changed.
This leads me to the following questions
Is there any complete, up-to-date and official documentation
what should be included in the repository
what should be in .gitignore
what is managed by Composer?
Is there any documentation how to do the transistion from the old directory structure to the new one in preperation of Symfony 3?
I thought I read all README.md, all release information and everything in "Living on the Edge" of the Symfony site, but somehow I missed this.
The clean way to install Symfony2 from scratch with composer, is to use the following command:
composer create-project symfony/framework-standard-edition my_project_name
This will ensure that all basic structures are created. After that, you can still insert your customisations from the previous project.
Then you can add everything – except app/config/parameters.yml as well as the contents of vendor/, app/cache and app/logs – to your repository.
About transitioning to SF3, I guess there’ll be an upgrade path as soon as SF3 is stable enough to create such a document.
1.1. that depends how you want people to be able to fetch your bundle
1.2. I share with you my own .gitignore: beware I use git for my own use to have a security for my files, not to allow people to get my bundle:
# Cache and logs (Symfony2)
/app/cache/*
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep
# Cache and logs (Symfony3)
/var/cache/*
/var/logs/*
!var/cache/.gitkeep
!var/logs/.gitkeep
# Parameters
/app/config/parameters.yml
/app/config/parameters.ini
# Managed by Composer
/app/bootstrap.php.cache
/var/bootstrap.php.cache
/bin/*
!bin/console
!bin/symfony_requirements
/vendor/
# Assets and user uploads
/web/bundles/
/web/uploads/
# PHPUnit
/app/phpunit.xml
/phpunit.xml
# Build data
/build/
# Composer PHAR
1.3. everything that is in composer.json

composer install does not update psr4 autoloader

I am using composer with a symfony project which require sonata-project/sonata-doctrine-orm-bundle and its dependencies (naturally with many other dependencies).
When I update symfony 2.3.6 to 2.5.5 and my vendors turn by turn, it updates sonata doctrine orm bundle which was written using PSR-0 autoloader and now uses PSR-4.
When composer finished to update all vendors and the symfony console command cache:clear run I get an error like class Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle can not be found.
When I look around to check what could be wrong, I discovered that the file vendor/composer/autoload_psr4.php is not updated with the path. The composer.json of sonata doctrine orm admin bundle is compliant with the paths I found in my vendor directory.
Does anyone have had the same or similar issue ? I can't find anything interesting about this...
Try to update composer, this was the issue I had when having problems with PSR-4 autoloading

Upgrade my Symfony2 app to use composer

I want to upgrade my app that I've developed with Symfony2 for users who want to use it do so with composer.
I don't know how to create composer.json file based on deps file.
This's my deps file: https://github.com/biruwon/Vecinos2.0/blob/master/deps
For example, what about with the bundles without composer.json? Or libraries how TCPDF upload on sourceforge?
If you help me here or with a pull request I'll be very thankful to you.
PD: I do this first and then update Symfony2 to Symfony2.1
For TCPDF it's quite easy it is on packagist already.
For bundles or libs that are not on packagist, the best way is to first get it to work in your project using a custom package repository in your composer.json, and once that's done sending a pull request to the original author with a composer.json and asking them to submit it to Packagist is the way to go.
Download the composer in symfony2 root folder:
curl -s https://getcomposer.org/installer | php
and execute
php composer.phar self-update
php composer.phar update
use this if you can update to the last version.

Resources