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
Related
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/
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
I already have a complete symfony 2.3 project and want to add cart and sale system on it with Sylius bundles. Sylius Cart Bundle and Sale Bundle use SyliusWebBundle and SyliusMoneyBundle. Sylius documents explain about installing a new Sylius project but not including Sylius to existing system. is there any way to install SyliusWebBundle and SyliusMoneyBundle on symfony 2 project?
You can install any of the bundles to your project using composer, just like you would any other symfony2 bundles.
You can find a list of the sylius bundles on the Packigist site.
The web bundle can be installed to your current project by simply typing, in your projects root dir:
composer require sylius/web-bundle
you will be prompted to select the version. "dev-master" is probably what you want.
Note: Depending on your setup the command you run might be
php composer.phar require sylius/web-bundle
If your not familiar with composer it's worth the time to look it up :).
Money bundle:
php composer.phar require sylius/money-bundle
There are documentations for each bundles of Sylius such as this for CartBundle and this for SaleBundle
I am attempting to use they EntityAudit extension for Doctrine2 in my Symfony2.1 app.
I'm very new to this, and I've just started realizing how many "correct" methods there have been for installing new bundles for Symfony over the years. Some sort of "Deps" file used to exist but does no longer? When installing Symfony, "using Composer" was an option -- but purely an option, it seemed. Now I'm starting to think that's not true.
In EntityAudit's instructions it refers to "Autoload", and based on other things, I'm apparently supposed to modify the registerNamespaces array in my Autoload.php. Except I don't have that. So I found this link where the guy indicates Symfony2.1 doesn't do that anymore in favor of using Composer.
I don't really know how to use Composer in this case though. I don't really know how to use it at all, actually, but I seem to have bumbled through doing 1 or 2 basic things in it -- "updating" itself and "installing" .. vendors? Anyway, I can find no instructions general enough to be adapted for this need. Thanks in advance for any help!
The deps file is used in 2.0 to manage dependencies. The 2.1 version uses the much better Composer dependency management tool.
Install with composer
First you'll need some basix about composer. For instance, read this article: http://net.tutsplus.com/tutorials/php/easy-package-management-with-composer/
Before you can use composer to install a bundle you should look for a Packagist package of that bundle. For the SimpleThings\EntityAuditBundle you should look for a simplethings/entity-audit-bundle package and it does exists: https://packagist.org/packages/simplethings/entity-audit-bundle
SIDENOTE
Packagist is the main archive for Composer.
If you are searching for a bundle, the best thing you can do is check out
KnpBundles, it is the unofficial achive of Symfony Bundles.
If a bundle contains a README file, it is displayed there and if it has a Packagist
package it shows a link to the package. It's a really usefull site to begin searching
for bundles.
Now you have the package name, you should determine the version you want to use. As this is a not-finished bundle we can use the latest version by using the dev-master version. But it could be possible that a dev-master version is for Symfony2.2 and we should use another version if we use Symfony2.1, this should be in the README file (in the Package, which you can view on Github or KnpBundles). If it isn't in the README, you can use the version you want. An example of the note about version can be found in the StofDoctrineExtensionsBundle.
Now we can add the bundle to our composer.json file and update the dependencies. You can do this manually:
Add it to the composer.json file:
{
...,
"require": {
...,
"simplethings/entity-audit-bundle": "dev-master"
}
}
Update the dependency
$ php composer.phar update simplethings/entity-audit-bundle
or update all dependencies
$ php composer.phar update
Or you can do this is one command:
Run this command (which includes the package in the composer.json and updates the package)
$ php composer.phar require simplethings/entity-audit-bundle:dev-master
Now the bundle is installed into our Symfony project (in vendor/simpletings/) and the autoloader recognises this bundle. The only thing we need to do now is registering the bundle in the AppKernel:
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
// ...
public function registerBundles()
{
$bundles = array(
...,
new SimpleThings\EntityAudit\SimpleThingsEntityAuditBundle(),
);
// ...
}
}
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.