I learn Symfony 2. I would like have example with SonataAdminBundle. I found:
http://sonata-project.org/bundles/news/2-0/doc/reference/installation.html
but this haven't first point.
i found:
[SonataAdminBundle]
git=http://github.com/sonata-project/SonataAdminBundle.git
target=/bundles/Sonata/AdminBundle
[SonataBlockBundle]
git=http://github.com/sonata-project/SonataBlockBundle.git
target=/bundles/Sonata/BlockBundle
[SonataCacheBundle]
git=http://github.com/sonata-project/SonataCacheBundle.git
target=/bundles/Sonata/CacheBundle
[SonatajQueryBundle]
git=http://github.com/sonata-project/SonatajQueryBundle.git
target=/bundles/Sonata/jQueryBundle
[SonataDoctrineORMAdminBundle]
git=http://github.com/sonata-project/SonataDoctrineORMAdminBundle.git
target=/bundles/Sonata/DoctrineORMAdminBundle
[KnpMenuBundle]
git=http://github.com/KnpLabs/KnpMenuBundle.git
target=/bundles/Knp/Bundle/MenuBundle
[KnpMenu]
git=http://github.com/KnpLabs/KnpMenu.git
target=/knp/menu
[Exporter]
git=http://github.com/sonata-project/exporter.git
target=/exporter
[SonataNewsBundle]
git=http://github.com/sonata-project/SonataNewsBundle.git
target=/bundles/Sonata/NewsBundle
and run bin/install vendors. . Install is correct. Id added line to AppKernel and autoload, and if i run:
php app/console sonata:easy-extends:generate SonataNewsBundle
i have error:
[InvalidArgumentException]
Bundle "ApplicationSonataNewsBundle" does not exist or it is not
enabled.
So i added:
new Application\Sonata\NewsBundle\ApplicationSonataNewsBundle(),
and run
php app/console sonata:easy-extends:generate SonataNewsBundle
then i have error:
PHP Fatal error: Class
'Application\Sonata\NewsBundle\ApplicationSonataNewsBundle' not found
in /home/lanox06/Projects/sym2/app/AppKernel.php on line 29
How can i make this? I would like testing these application.
You should move the ./app/Application folder from ./app to the ./src directory.
An other solution is to add the --dest=src option like this :
php app/console sonata:easy-extends:generate --dest=src SonataNewsBundle
Related
I want to create a new entity in my ORO platform application by using the make:entity command from the MakerBundle.
I expect it to create an entity in my bundle Acme\Bundle\TestBundle which I set in my config_dev.yml by using:
maker:
root_namespace: 'Acme\Bundle\TestBundle'
So I execute
bin/console make:entity Test
which returns
! [NOTE] It looks like your app may be using a namespace other than "Acme\Bundle\TestBundle".
!
! To configure this and make your life easier, see:
! https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html#configuration
created: src/Acme/Bundle/TestBundle/Entity/Test.php
created: src/Acme/Bundle/TestBundle/Repository/TestRepository.php
[ERROR] Only annotation mapping is supported by make:entity, but the
<info>Acme\Bundle\TestBundle\Entity\Test</info> class uses a different format. If you would like
this command to generate the properties & getter/setter methods, add your mapping configuration, and then
re-run this command with the <info>--regenerate</info> flag.
I've tried to run the command once again, which works. But obviously this is not the way how it's meant to work. So how can I fix this mapping error?
I started with the standard Symfony 5 project by using Symfony new myapp.
I add the config file in config/packages/dev/maker.yaml
maker:
root_namespace: 'App\Core'
To generate the entity in the src/Core folder, I got the following error:
➜ symfony console make:entity Post
created: src/Core/Entity/Post.php
created: src/Core/Repository/PostRepository.php
[ERROR] Only annotation mapping is supported by make:entity, but the <info>App\Core\Entity\Post</info> class uses
a different format. If you would like this command to generate the properties & getter/setter methods, add your
mapping configuration, and then re-run this command with the <info>--regenerate</info> flag.
To avoid showing the error in the console, I install the patch created by vklux / maker-bundle-force-annotation
Step 1: install package
composer require cweagans/composer-patches
Step 2: apply the patch in composer.json
{
// {...} composer.json content
"extra": {
"patches": {
"symfony/maker-bundle": {
"Provide flag to force annotation in make entity command": "https://raw.githubusercontent.com/vklux/maker-bundle-force-annotation/master/maker-force-annotation-flag.patch"
}
}
}
}
Step 3: composer update
composer update
Step 4: try make:entity with the additional command option
➜ symfony console make:entity Post --force-annotation
created: src/Core/Entity/Post.php
created: src/Core/Repository/PostRepository.php
Entity generated! Now let's add some fields!
You can always add more fields later manually or by re-running this command.
New property name (press <return> to stop adding fields):
>
✅ 🚀 👍 Everything works fine now.
It's a bug in the doctrine version please try this version good luck
composer req doctrine/doctrine-bundle:2.2
I found a solution to create new entities with Symfony maker using doctrine/doctrine-bundle version higher than 2.2.4
These steps worked for me with:
"doctrine/doctrine-bundle": "^2.7"
PHP 8.1 (I migrate from php 7.4 in my case)
STEP 1: replace type: annotation by type: attribute inside doctrine.yaml
STEP 2: Enter entity root with namespace:
symfony console make:entity App\Entity\test
I am trying to configure the bundle from : https://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html
and when I try to run the command :
$ php bin/console doctrine:fixtures:load
getting error:
In LoadDataFixturesDoctrineCommand.php line 95:
Could not find any fixture services to load.
You need to update (app/config/services.yml)
services:
resource: '../../src/DataFixtures/*'
https://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html
Other problem is here in to the above tutorial
// src/DataFixtures/AppFixtures.php
namespace App\DataFixtures;
name space should be :
namespace DataFixtures;
I've found this page :
https://gist.github.com/rtconner/40b415073378da28b2bf
where it's shown a Service provider to be added in L5 in order to manage sftp connection driver in filesystem configs. Which is supposed to solve a issue.
Anyway once I executed via console:
php artisan make:provider SftpServiceProvider
And edited the SftpServiceProvider class as shown in the above webpage.
I went to config/app.php to add
'providers' => [
...
'App\Providers\SftpServiceProvider',
...
]
I tried a
composer dump-autoload --optimize (with and without the option)
But always I get a error:
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'App\Providers\SftpServiceProvider' not found
In fact, I cannot see in my vendor/composer/autoload_classmap.php
the line addressing to SftpServiceProvider
Also executing a
composer update #will not be ok.
Again the errors:
- Script php artisan clear-compiled handling the post-update-cmd event returned with an error
- [RuntimeException] Error Output: PHP Fatal error: Class 'App\Providers\SftpServiceProvider' not found
What do I miss in the ServiceProvider creation procedure?
Thanks
I am trying to install symfony2 JMS DI Extra bundle.
But i keep getting this error
Fatal error: Interface 'CG\Proxy\InterceptorLoaderInterface' not found
in
/home/xxxxx/public_html/XXXX/Symfony/vendor/bundles/JMS/AopBundle/Aop/InterceptorLoader.php
on line 30
I have found the solution here
https://github.com/schmittjoh/JMSAopBundle/issues/7
But could not able to understand where to fix the path
I think that's cg-library is missing. Open a command prompt into your Symfony vendor folder and issue:
git clone https://github.com/schmittjoh/cg-library.git cg-library
The add cg-library into your deps file:
[cg-library]
git=https://github.com/schmittjoh/cg-library.git
target=/cg-library
i am trying out the Doctrine 2 sandbox. downloaded the main Doctrine 2 ORM from http://github.com/doctrine/doctrine2 the dbal from http://github.com/doctrine/dbal and common from http://github.com/doctrine/common. placed the packages in approparate folders ...
D:\ResourceLibrary\Frameworks\Doctrine\lib\Doctrine\ORM
D:\ResourceLibrary\Frameworks\Doctrine\lib\vendor\doctrine-common\lib\Doctrine\Common
D:\ResourceLibrary\Frameworks\Doctrine\lib\vendor\doctrine-dbal\lib\Doctrine\DBAL
from the sandbox folder i tried to get the version to see if everything works ok ...
D:\ResourceLibrary\Frameworks\Doctrine\tools\sandbox>php doctrine.php -V
Doctrine Command Line Interface version 2.0.0BETA4-DEV
looks ok.
D:\ResourceLibrary\Frameworks\Doctrine\tools\sandbox>php doctrine.php orm:schema-tool:create ./Entities
[RuntimeException]
Too many arguments.
orm:schema-tool:create [--dump-sql] [-h|--help] [-q|--quiet] [-v|--verbose] [-V|--version] [-c|--color] [-n|--no-interaction] command
then fails ...
how can i fix this?
This is a known problem with the tutorial. Try removing the ./Entities argument as suggested in the bug report:
http://www.doctrine-project.org/jira/browse/DWEB-53?page=com.atlassian.jira.ext.fisheye%3Afisheye-issuepanel.
Do:
php doctrine.php orm:schema-tool:create --dump-sql
For a running example of the Cookbook code that can be downloaded, see here.