sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Using sonata with Symfony 2.8 and 3 ? #3596

Closed ghost closed 8 years ago

ghost commented 8 years ago

hello,

well i can't install sonata on my frech install of symfony2 can explain me what is wrong please ?

root [/var/www/html_prod/CMS-Demo] > symfony new my_project_demoSonata 2.8

 Downloading Symfony...

    5.17 MB/5.17 MB ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  100%

 Preparing project...

 ✕  Symfony 2.8.2 was successfully installed but your system doesn't meet its
     technical requirements! Fix the following issues before executing
     your Symfony application:

 * date.timezone setting must be set
   > Set the "date.timezone" setting in php.ini* (like Europe/Paris).

 After fixing these issues, re-check Symfony requirements executing this command:

   php my_project_demoSonata/app/check.php

 Then, you can:

    * Change your current directory to /var/www/html_prod/CMS-Demo/my_project_demoSonata

    * Configure your application in app/config/parameters.yml file.

    * Run your application:
        1. Execute the php app/console server:run command.
        2. Browse to the http://localhost:8000 URL.

    * Read the documentation at http://symfony.com/doc

and :

root [/var/www/html_prod/CMS-Demo/my_project_demoSonata] > php  composer.phar require sonata-project/admin-bundle "2.3.*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - sonata-project/admin-bundle 2.3.7 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.6 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.5 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.4 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.3 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.2 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.1 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.0 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - Installation request for sonata-project/admin-bundle 2.3.* -> satisfiable by sonata-project/admin-bundle[2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.3.6, 2.3.7].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.
greg0ire commented 8 years ago

Sonata 2.3 is not compatible with symfony 3.0. Sonata 2.4 might be.

nlzet commented 8 years ago

@greg0ire the issue also mensions Symfony 2.8, which should be installable ?

@ychoucha The error occurs because symfony 2.8 by default requires (dev) : sensio/generator-bundle": "~3.0"

I'm not sure if this minimum requirement is correct, you can fix this by first executing: composer require sensio/generator-bundle "~2.3" --dev

And then you can install the admin bundle with: composer require sonata-project/admin-bundle "2.3.*"

But you should search if the 2.3 generator bundle is compatible with symfony 2.8

Do note: the master of the sonata admin bundle, allows the generator bundle ~2.3|~3.0. But this version is not yet stable/tagged

greg0ire commented 8 years ago

Oh my bad, the dependency is correct, the ~3.0 version is marked as compatible with symfony "~2.7". I think sonata should allow it.

ghost commented 8 years ago

ok so sonata is not compatible with stable release of symfony 2.8 with end of support Nov. 2018 ??

so we have to use Sonata with a old symfony framwork version ? like the 2.4 but we can't install it :

root [/var/www/html_prod/CMS-Demo] > symfony new my_project_demoSonata 2.4
  [RuntimeException]
  The selected version (2.4.10) cannot be installed because it belongs
  to an unmaintained Symfony branch which is not compatible with this installer.
  To solve this issue install Symfony manually executing the following command:
  composer create-project symfony/framework-standard-edition /var/www/html_prod/CMS-Demo/my_project_demoSonata 2.4
  .10

so so so how use sonota please ?

greg0ire commented 8 years ago

I was speaking about sonata 2.4 . Not symfony 2.4 ;)

ghost commented 8 years ago

ok so what symfony version we need to instal to play with sonata

greg0ire commented 8 years ago

You can use sf 3.0 and sonata 2.4@dev I guess, but there are more stable choices like sf 2.7, sonata 2.3

ghost commented 8 years ago

well thanks,

that's not cool to start a project with no sf stable version ?

greg0ire commented 8 years ago

sf 3.0 is stable, but sonata 2.4 is not stable yet. Starting a project with any dependency unstable is risky (you must be ready to change your code as soon as you upgrade the dependency). I would advise to start with sf 2.8 and sonata 2.3, and then upgrade sf and sonata when sonata 2.4 is ready.

ghost commented 8 years ago

ok so i try the install with sf 2.8 and sonata 2.3 : i do this terminal video of my process install --> https://asciinema.org/a/cm5035hej5u0565b3wvb73c2w

and no way to install it :/


root [/var/www/html_prod/CMS-Demo/my_project_demoSonata] > php composer.phar require sonata-project/admin-bundle "2.3.*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - sonata-project/admin-bundle 2.3.7 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.6 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.5 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.4 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.3 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.2 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.1 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.0 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - Installation request for sonata-project/admin-bundle 2.3.* -> satisfiable by sonata-project/admin-bundle[2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.3.6, 2.3.7].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.
greg0ire commented 8 years ago

The generator bundle requirement should probably be changed to ~2.3|~3.0 on the 2.3 branch of Sonata. @sonata-project/contributors ? What do you think?

ghost commented 8 years ago

Si i have to found sf 2.4 with so 2.3

greg0ire commented 8 years ago

Si i have to found sf 2.4 with so 2.3

What?

soullivaneuh commented 8 years ago

The generator bundle requirement should probably be changed to ~2.3|~3.0 on the 2.3 branch of Sonata. @sonata-project/contributors ? What do you think?

It's already the case for 2.4.x.

I'm not sure we can easily change this on 2.3 without breaking anything... cc @rande

greg0ire commented 8 years ago

The generator bundle does not have an upgrade file :(

dbu commented 8 years ago

does sonata admin actually need the generator bundle? i thought that is about creating bundles in a command and similar things...

jvasseur commented 8 years ago

Sonata admin use it for the generate:admin command.

greg0ire commented 8 years ago

Looks like there is a test for it. We should just make a P.R. and let the tests run.

greg0ire commented 8 years ago

Looks like tests are passing.

ghost commented 8 years ago

ok so i have try to install sonata and i m stuck :/

I have triend with symfony 2.8 and sonata 2.3 :

root [/var/www/sonata-demo] > php composer.phar require sonata-project/admin-bundle
Using version ^2.3 for sonata-project/admin-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - sonata-project/admin-bundle 2.3.7 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.6 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.5 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.4 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.3 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.2 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.1 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - sonata-project/admin-bundle 2.3.0 requires sensio/generator-bundle ~2.3 -> no matching package found.
    - Installation request for sonata-project/admin-bundle ^2.3 -> satisfiable by sonata-project/admin-bundle[2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.3.6, 2.3.7].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.
ghost commented 8 years ago

and on the web site of symfony i can"t get a old symfony version :!

https://symfony.com/roadmap?version=2.4#checker

dbu commented 8 years ago

well, 2.4 was not a long term support version, so its not maintained anymore. afaik 2.3 is about to end, but 2.7 will be maintained for a while still.

ghost commented 8 years ago

im sorry, but even the 2.7 not working with symfony :

show what i do :

https://asciinema.org/a/3uslv0wktz9cr2b2g1o5vs789

i finish with the error :

Your requirements could not be resolved to an installable set of packages.

greg0ire commented 8 years ago

Try again after running what @nlzet recommended : composer require sensio/generator-bundle "~2.3" --dev. Alternatively, you can edit composer.json directly to fix that.

And please stop using asciinema, it is very pretty, but brings nothing to the table and prevents at least me to see what exactly you used when requiring sensio/generator-bundle. Use it if you really need to show us color or progress bars.

greg0ire commented 8 years ago

3604 has been fixed, which means you should be also be able to install the 2.3@dev version of the admin bundle without changing the generator requirements.

ghost commented 8 years ago

ok cool works with :+1:

symfony new my_project_demoSonata 2.7 php composer.phar require "sensio/generator-bundle" php composer.phar require sonata-project/admin-bundle "2.3" --dev php composer.phar require sonata-project/doctrine-orm-admin-bundle --prefer-dist

ok i will never use again asciinema (but he looking cool :/)

thanks i will start using sonata now :)

greg0ire commented 8 years ago

ok i will never use again asciinema (but he looking cool :/)

I know, it's really nice, but should not be overused :)

php composer.phar require sonata-project/admin-bundle "2.3" --dev

This does not do what you think it does, it adds sonata-project/admin-bundle 2.3 to your dev requirements (have a look at your composer.json), you'll see what I mean

php composer.phar require "sensio/generator-bundle"

Shoud be php composer require sensio/generator-bundle "~2.3" --dev

I don't know what you have now, but if it works, guess you can play with Sonata and sort that out later.

ghost commented 8 years ago

well well well i talk to fast :

this i do to install symfony 2.7 an sonata 2.3 :

symfony new my_project_demoSonata 2.7
cp composer.phar my_project_demoSonata/
cd my_project_demoSonata/
php composer.phar require "sensio/generator-bundle"  "~2.3" --dev
php composer.phar require sonata-project/admin-bundle "2.3" --dev
php composer.phar require sonata-project/doctrine-orm-admin-bundle --prefer-dist
php app/console cache:clear
chmod 777 -R app/cache
chmod 777 -R app/logs
cd ..
chown ayoub:www-data -R  my_project_demoSonata/

and i have this error when i logging :

FatalErrorException in AdminListBlockService.php line 0: Compile Error: Declaration of Sonata\AdminBundle\Block\AdminListBlockService::validateBlock() must be compatible with Sonata\BlockBundle\Block\BlockAdminServiceInterface::validateBlock(Sonata\CoreBundle\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block)

ghost commented 8 years ago

ok works with that :

symfony new my_project_demoSonata 2.7
cp composer.phar my_project_demoSonata/
cd my_project_demoSonata/
pwd
php composer.phar require "sensio/generator-bundle"   "~2.3" --dev
pwd
php composer.phar require sonata-project/admin-bundle
pwd
php composer.phar require sonata-project/doctrine-orm-admin-bundle --prefer-dist
pwd
php app/console cache:clear
chmod 777 -R app/cache
chmod 777 -R app/logs
cd ..
chown ayoub:www-data -R  my_project_demoSonata/
greg0ire commented 8 years ago

Great! I'm sure the pwds helped a lot :stuck_out_tongue_winking_eye:

ghost commented 8 years ago

well i m hope sonata will be more stable

ghost commented 8 years ago

Ok so i change my little script automaticly the last composer.phar so this the new little script :

symfony new my_project_demoSonata 2.7
cd my_project_demoSonata/
php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
php -r "if (hash('SHA384', file_get_contents('composer-setup.php')) === 'fd26ce67e3b237fffd5e5544b45b0d92c41a4afe3e3f778e942e43ce6be197b9cdc7c251dcde6e2a52297ea269370680') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); }"
php composer-setup.php
php -r "unlink('composer-setup.php');"
php composer.phar require "sensio/generator-bundle"   "~2.3" --dev
php composer.phar require sonata-project/admin-bundle
php composer.phar require sonata-project/doctrine-orm-admin-bundle --prefer-dist
php app/console cache:clear
chmod 777 -R app/cache
chmod 777 -R app/logs
cd ..
chown ayoub:www-data -R  my_project_demoSonata/

so now we have a symfony 2.7 installed with all necessary of sonata !

now let's start to make the first to make it real working : :)

1> Enable the Bundle in the project :

so this my app/Appkernel.php :

...
    public function registerBundles()
    {
        $bundles = array(
            // ...

            // These are the other bundles the SonataAdminBundle relies on
            new Sonata\CoreBundle\SonataCoreBundle(),
            new Sonata\BlockBundle\SonataBlockBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),

            // And finally, the storage and SonataAdminBundle
            new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
            new Sonata\AdminBundle\SonataAdminBundle(),
    // ...
}

Configure the installed Bundles :+1:

# app/config/config.yml
sonata_block:
    default_contexts: [cms]
    blocks:
        # enable the SonataAdminBundle block
        sonata.admin.block.admin_list:
            contexts: [admin]
        # ...

3> importing routing :

# app/config/routing.yml
admin_area:
    resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
    prefix: /admin

4> preparing the place :

$ php app/console cache:clear
$ php app/console assets:install

Now we can go to ---> http://localhost/app_dev.php/admin

admin title_dashboard - mozilla firefox

and we have sonata admin ready to works, now let's play with doctrine :)

Create the table :

 php app/console doctrine:generate:entity --entity="AppBundle:Category" --fields="name:string(255)" --no-interaction
 php app/console doctrine:generate:entity --entity="AppBundle:BlogPost" --fields="title:string(255) body:text draft:boolean" --no-interaction

ok i do th stuff from the documentation and works

thanks :)

greg0ire commented 8 years ago

Can you format your message properly?

brave44 commented 8 years ago

How to istall sonata-project/admin-bundle with Symfony3? Still can not do it.

- sonata-project/admin-bundle 2.3.7 requires sensio/generator-bundle ~2.3 -> no matching package found.

If I try require sensio/generator-bundle "~2.3" --dev, it says I need to remove symfony 3.0.3

EDIT: Oh, I got it, just need dev-master version of sonata. So, composer require sonata-project/admin-bundle "dev-master" did the trick. Thx, @nlzet.

Mangetsu commented 8 years ago

if you still have issues with SF3 and Sonata install, please refere to my composer requirement bellow, i managed to get Sf3, Sonata and FOSUser to work perfectly (dispite some minor fixes to avoid deprecated/removed services)

"require": { "php": ">=5.5.9", "symfony/symfony": "3.0.*", "doctrine/orm": "^2.5", "doctrine/doctrine-bundle": "^1.6", "doctrine/doctrine-cache-bundle": "^1.2", "symfony/swiftmailer-bundle": "^2.3", "symfony/monolog-bundle": "^2.8", "sensio/distribution-bundle": "^5.0", "sensio/framework-extra-bundle": "^3.0.2", "incenteev/composer-parameter-handler": "^2.0", "symfony/security-acl": "^3.0", "sonata-project/admin-bundle": "dev-master", "sonata-project/easy-extends-bundle": "^2.1", "sonata-project/doctrine-orm-admin-bundle": "dev-master", "friendsofsymfony/user-bundle": "dev-master", "sonata-project/user-bundle": "dev-add_support_for_fos_user2@dev", "sensio/generator-bundle": "^3.0" },

FOSUser removed services fix : `services:

# Fix FOSUserBundle issue
fos_user.doctrine_registry:
    alias: doctrine

fos_user.entity_manager:
    alias: fos_user.object_manager`
lacatoire commented 8 years ago

Hello, I've tryed what you gave Mangetsu, but i still have a problem to install sonata-project/user-bundle

it seems the corebundle of sonata is not compatible, do u know an issue? because if i put it in 3.0 i got the error with the sonata user bundle capture

` "php": ">=5.5.9", "symfony/symfony": "3.0.*", "doctrine/orm": "^2.5", "doctrine/doctrine-bundle": "^1.6", "doctrine/doctrine-cache-bundle": "^1.2", "symfony/swiftmailer-bundle": "^2.3", "symfony/monolog-bundle": "^2.8", "sensio/distribution-bundle": "^5.0", "sensio/framework-extra-bundle": "^3.0.2", "incenteev/composer-parameter-handler": "^2.0", "stof/doctrine-extensions-bundle": "~1.1", "doctrine/doctrine-fixtures-bundle": "~2.2", "twig/extensions": "~1.0", "symfony/assetic-bundle": "^2.8", "symfony/options-resolver": "~2.3", "symfony/form": "~2.3", "symfony/yaml": "~2.3", "symfony/security-bundle": "~2.3", "kriswallsmith/buzz": "~0.13", "coresphere/console-bundle": "dev-master", "pugx/autocompleter-bundle": "^1.2", "stof/doctrine-extensions-bundle": "~1.1", "sonata-project/doctrine-orm-admin-bundle": "dev-master",

    "sonata-project/core-bundle": "^2.3",
    "sonata-project/block-bundle": "^3.1",
    "knplabs/knp-menu-bundle": "^2.0",
    "sonata-project/easy-extends-bundle": "^2.1",
    "sonata-project/cache-bundle": "^2.2",

    "symfony/security-acl": "^3.0",
    "sonata-project/admin-bundle": "dev-master",
    "friendsofsymfony/user-bundle": "dev-master",
    "sonata-project/user-bundle": "dev-add_support_for_fos_user2@dev"
    `
soullivaneuh commented 8 years ago

you need to add sonata-project/core-bundle ^3.0.

lacatoire commented 8 years ago

yes i did this, but i got this error, i don't know how to solve this

sonata-project/user bundle dev-add_support_for_fos_user2 requires sonata-project/core-bundle "2.3,>=2.3.10

soullivaneuh commented 8 years ago

Please note that user bundle dev-add_support_for_fos_user2 is an experimental and unstable branch.

If you really want to use it, you might have to use composer version aliases.

https://getcomposer.org/doc/articles/aliases.md#require-inline-alias

lacatoire commented 8 years ago

Okay, thank you Are there maybe another way to install sonata user?

soullivaneuh commented 8 years ago

Yes, using stable version. But this will not be compatible with FOSUser 2.x.

lacatoire commented 8 years ago

I've found a version wich is working, but now i've a problem with mediabundle on a service:

`"require": { "php": ">=5.5.9", "symfony/symfony": "3.0.*", "doctrine/orm": "^2.5", "doctrine/doctrine-bundle": "^1.6", "doctrine/doctrine-cache-bundle": "^1.2", "symfony/swiftmailer-bundle": "^2.3", "symfony/monolog-bundle": "^2.8", "sensio/distribution-bundle": "^5.0", "sensio/framework-extra-bundle": "^3.0.2", "incenteev/composer-parameter-handler": "^2.0", "stof/doctrine-extensions-bundle": "~1.1", "doctrine/doctrine-fixtures-bundle": "~2.2", "friendsofsymfony/user-bundle": "dev-master", "twig/extensions": "~1.0", "symfony/assetic-bundle": "^2.8", "symfony/options-resolver": "~2.3", "symfony/form": "~2.3", "symfony/yaml": "~2.3", "symfony/security-bundle": "~2.3", "kriswallsmith/buzz": "~0.13", "coresphere/console-bundle": "dev-master", "pugx/autocompleter-bundle": "^1.2", "stof/doctrine-extensions-bundle": "~1.1",

    "sonata-project/doctrine-orm-admin-bundle": "^3.0",
    "sonata-project/admin-bundle": "^3.4",
    "sonata-project/core-bundle": "^3.0",
    "sonata-project/block-bundle": "^3.1",
    "knplabs/knp-menu-bundle": "^2.0",
    "sonata-project/easy-extends-bundle": "^2.1",
    "sonata-project/cache-bundle": "^2.2",
    "sonata-project/media-bundle": "^3.0",
    "sonata-project/seo-bundle": "^2.0",
    "sonata-project/classification-bundle": "^3.1",
    "jms/serializer-bundle": "^1.1"    
},
"require-dev": {
    "sensio/generator-bundle": "^3.0",
    "symfony/phpunit-bridge": "^2.7"
},`

So I did the installation with mediabundle and then classificationbundle, and it works, I updated my db,

but i have an new error on sonata/media/media/create: You have requested a non-existent service "request". Did you mean one of these: "request_stack", "router.request_context", "monolog.logger.request", "assetic.request_listener", "validate_request_listener", "data_collector.request"?

and on admin/sonata/media/media/list Notice: Undefined index: entity

Does anybody have an idea where i have to search or maybe an answer? Thank you

soullivaneuh commented 8 years ago

@lacpandore Not related to this issue.

  1. Read and re-read carefully the documentation
  2. Ask your question on SO
  3. If you think it's a bug, try to find the related GitHub issue on the right repository
  4. If no issue related to this bug, feel free to create one respecting the bug report template
nikunjkabariya commented 7 years ago

Hello,

How to use sonata admin project with symfony 3.2.* having translation features (Multilingual support - form labels, messages, validators and doctrine ORM translatable support - <what should be database structure?>). Can anybody have example which i can use? OR Can anybody guide me how to implement it?

Thanks

soullivaneuh commented 7 years ago

@nikunjkabariya This is not related to the issue and not an issue anymore.

Please ask your question on SO.

Locking this thread.