SonataAdminBundle - does not work in production environment

Created on 20 Sep 2011  路  8Comments  路  Source: sonata-project/SonataAdminBundle

I setuped fresh copy of the symfony, created new bundle, created a couple entities and admin class.
For some reasons in development environment I got correct dashboard, but when I try production environment dashboard is empty. Screenshot are here http://gb.kiev.ua/initial.jpg

I had version, that its some kind of tricky configuration issue and put in config_prod.yml exactly the same config, as in config_dev.yml - it doesnt help.

Looks like service injection does not work in production environment and I dont have any ideas why.
Any suggestions what could be the reason? Google find only my topic on official forum
http://forum.symfony-project.org/viewtopic.php?f=23&t=37064
:)

I put related code above

services.xml





    
    
    
            
            
            Vido\AdminBundle\Entity\News
        VidoAdminBundle:PostAdmin
    
    


config_dev.yml

imports:
    - { resource: config.yml }

framework:
    router:   { resource: "%kernel.root_dir%/config/routing_dev.yml" }
    profiler: { only_exceptions: false }

web_profiler:
    toolbar: true
    intercept_redirects: false

monolog:
    handlers:
        main:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug
        firephp:
            type:  firephp
            level: info

assetic:
    use_controller: true

config_prod.yml

imports:
    - { resource: config.yml }

#doctrine:
#    metadata_cache_driver: apc
#    result_cache_driver: apc
#    query_cache_driver: apc

monolog:
    handlers:
        main:
            type:         fingers_crossed
            action_level: error
            handler:      nested
        nested:
            type:  stream
            path:  %kernel.logs_dir%/%kernel.environment%.log
            level: debug

Most helpful comment

Solution is php app/console cache:clear --env=prod --no-debug

All 8 comments

you need to check the contents of the generated container and see if admin classes are set

thanks for the help and sorry if you get a lot of email notifications trying to fix comment look, github comments parser kill me :)

as I understand, you are talking about

 <div class="sonata-ba-content"> 
?
It exists in source

html code of the url http://localhost:9999/app.php/admin/dashboard

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

                    <!-- jQuery code -->
            <link rel="stylesheet" href="/bundles/sonatajquery/themes/flick/jquery-ui-1.8.6.custom.css" type="text/css" media="all" />

            <!-- blueprint code -->
            <link rel="stylesheet" href="/bundles/sonatablueprint/screen.css" type="text/css" media="screen, projection">
            <link rel="stylesheet" href="/bundles/sonatablueprint/print.css" type="text/css" media="print">

            <!--[if lt IE 8]><link rel="stylesheet" href="/bundles/sonatablueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->

            <!-- base application asset -->
            <link rel="stylesheet" href="/bundles/sonataadmin/css/layout.css" type="text/css" media="all">
            <link rel="stylesheet" href="/bundles/sonataadmin/css/colors.css" type="text/css" media="all">

                    <script src="/bundles/sonatajquery/jquery-1.4.4.js" type="text/javascript"></script>
            <script src="/bundles/sonatajquery/jquery-ui-1.8.6.custom.js" type="text/javascript"></script>
            <script src="/bundles/sonatajquery/jquery-ui-i18n.js" type="text/javascript"></script>

            <script src="/bundles/sonataadmin/qtip/jquery.qtip-1.0.0-rc3.min.js" type="text/javascript"></script>
            <script src="/bundles/sonataadmin/jquery/jquery.form.js" type="text/javascript"></script>
            <script src="/bundles/sonataadmin/base.js" type="text/javascript"></script>

        <title>
            title_dashboard        </title>
    </head>
    <body>



        <div class="container">
            <div class="span-24 last header">
                <div class="span-20">
                    <a href="http://localhost:9999/app.php/admin/dashboard" class="home">Admin</a>
                </div>

                <div class="span-4 last">
                                    </div>
            </div>

            <div class="span-24 last content clear">
                <div class="right">
                                    </div>

                <div class="sonata-ba-breadcrumbs">
                    <h1>
                    title_dashboard                    </h1>
                </div>








            </div>


            <div class="span-24 last content clear">


                                            <div class="sonata-ba-content">

</div>





            </div>

            <!-- footer -->
            <div class="span-24 last">

                            </div>
        </div>
    </body>
</html>

no I am talking about the dependency injection container in the cache folder

got you. I am new in all this stuff, sorry about stupid questions :)

my bundle name is Vido/AdminBundle, entity name Video, admin class name Admin/VideoAdmin.php

I searched for the string VideoAdmin in folder app/cache/dev/ and founded a couple files with such a string
In folder app/cache/prod/ - no such files founded.

Below is some additional info in case if it will help you.
folder app/cache/prod/annotations/ have such a files.

Sonata-AdminBundle-Controller-CoreController#dashboardAction.cache.php
Sonata-AdminBundle-Controller-CRUDController#batchAction.cache.php
Sonata-AdminBundle-Controller-CRUDController#batchActionDelete.cache.php
Sonata-AdminBundle-Controller-CRUDController#configure.cache.php
Sonata-AdminBundle-Controller-CRUDController#createAction.cache.php
Sonata-AdminBundle-Controller-CRUDController#deleteAction.cache.php
Sonata-AdminBundle-Controller-CRUDController#editAction.cache.php
Sonata-AdminBundle-Controller-CRUDController#getBaseTemplate.cache.php
Sonata-AdminBundle-Controller-CRUDController#isXmlHttpRequest.cache.php
Sonata-AdminBundle-Controller-CRUDController#listAction.cache.php
Sonata-AdminBundle-Controller-CRUDController#redirectTo.cache.php
Sonata-AdminBundle-Controller-CRUDController#render.cache.php
Sonata-AdminBundle-Controller-CRUDController#renderJson.cache.php
Sonata-AdminBundle-Controller-CRUDController#setContainer.cache.php
Sonata-AdminBundle-Controller-CRUDController#showAction.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#createForm.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#createFormBuilder.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#createNotFoundException.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#forward.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#generateUrl.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#get.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#getDoctrine.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#getRequest.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#has.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#redirect.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#render.cache.php
Symfony-Bundle-FrameworkBundle-Controller-Controller#renderView.cache.php
Symfony-Bundle-TwigBundle-Controller-ExceptionController#showAction.cache.php
Symfony-Component-DependencyInjection-ContainerAware#setContainer.cache.php
Vido-AdminBundle-Controller-DefaultController#indexAction.cache.php
Vido-AdminBundle-Controller-DefaultController.cache.php
Vido-AdminBundle-Controller-VideoAdminController.cache.php

all of them have size 35 bytes and content

<?php return unserialize('a:0:{}');

except file Vido-AdminBundle-Controller-DefaultController#indexAction.cache.php, it have content

return unserialize('a:2:{i:0;O:54:"Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Route":6:{s:10:"' . "\0" . '*' . "\0" . 'service";N;s:51:"' . "\0" . 'Symfony\\Component\\Routing\\Annotation\\Route' . "\0" . 'pattern";s:13:"/hello/{name}";s:48:"' . "\0" . 'Symfony\\Component\\Routing\\Annotation\\Route' . "\0" . 'name";N;s:56:"' . "\0" . 'Symfony\\Component\\Routing\\Annotation\\Route' . "\0" . 'requirements";a:0:{}s:51:"' . "\0" . 'Symfony\\Component\\Routing\\Annotation\\Route' . "\0" . 'options";a:0:{}s:52:"' . "\0" . 'Symfony\\Component\\Routing\\Annotation\\Route' . "\0" . 'defaults";a:0:{}}i:1;O:57:"Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Template":3:{s:11:"' . "\0" . '*' . "\0" . 'template";N;s:9:"' . "\0" . '*' . "\0" . 'engine";s:4:"twig";s:7:"' . "\0" . '*' . "\0" . 'vars";a:0:{}}}');

as I understand, all this stuff are read from app/cache/prod/appProdProjectContainer.php
I have checked for the string Vido - it exists in the file app/cache/prod/appProdProjectContainer.php in different places

In dev cache folder I have founded file appDevDebugProjectContainer.xml, it have services declaration with VideoAdmin in it, no such an XML files exists in app/cache/prod/

./app/console container:debug --env=prod | grep 'admin'

thanks, got response

sonata.admin.builder.filter.factory           container Sonata\AdminBundle\Filter\FilterFactory
sonata.admin.builder.orm_datagrid             container Sonata\AdminBundle\Builder\ORM\DatagridBuilder
sonata.admin.builder.orm_form                 container Sonata\AdminBundle\Builder\ORM\FormContractor
sonata.admin.builder.orm_list                 container Sonata\AdminBundle\Builder\ORM\ListBuilder
sonata.admin.builder.orm_show                 container Sonata\AdminBundle\Builder\ORM\ShowBuilder
sonata.admin.form.extension.field             container Sonata\AdminBundle\Form\Extension\Field\Type\FormTypeFieldExtension
sonata.admin.form.filter.type.choice          container Sonata\AdminBundle\Form\Type\Filter\ChoiceType
sonata.admin.form.filter.type.default         container Sonata\AdminBundle\Form\Type\Filter\DefaultType
sonata.admin.form.filter.type.number          container Sonata\AdminBundle\Form\Type\Filter\NumberType
sonata.admin.form.type.admin                  container Sonata\AdminBundle\Form\Type\AdminType
sonata.admin.form.type.array                  container Sonata\AdminBundle\Form\Type\ImmutableArrayType
sonata.admin.form.type.boolean                container Sonata\AdminBundle\Form\Type\BooleanType
sonata.admin.form.type.collection             container Sonata\AdminBundle\Form\Type\CollectionType
sonata.admin.form.type.model                  container Sonata\AdminBundle\Form\Type\ModelType
sonata.admin.form.type.model_reference        container Sonata\AdminBundle\Form\Type\ModelReferenceType
sonata.admin.guesser.orm_datagrid             container Sonata\AdminBundle\Guesser\ORM\FilterTypeGuesser
sonata.admin.guesser.orm_datagrid_chain       container Sonata\AdminBundle\Guesser\TypeGuesserChain
sonata.admin.guesser.orm_list                 container Sonata\AdminBundle\Guesser\ORM\TypeGuesser
sonata.admin.guesser.orm_list_chain           container Sonata\AdminBundle\Guesser\TypeGuesserChain
sonata.admin.guesser.orm_show                 container Sonata\AdminBundle\Guesser\ORM\TypeGuesser
sonata.admin.guesser.orm_show_chain           container Sonata\AdminBundle\Guesser\TypeGuesserChain
sonata.admin.helper                           container Sonata\AdminBundle\Admin\AdminHelper
sonata.admin.manager.orm                      container Sonata\AdminBundle\Model\ORM\ModelManager
sonata.admin.orm.filter.type.boolean          prototype Sonata\AdminBundle\Filter\ORM\BooleanFilter
sonata.admin.orm.filter.type.callback         prototype Sonata\AdminBundle\Filter\ORM\CallbackFilter
sonata.admin.orm.filter.type.choice           prototype Sonata\AdminBundle\Filter\ORM\ChoiceFilter
sonata.admin.orm.filter.type.model            prototype Sonata\AdminBundle\Filter\ORM\ModelFilter
sonata.admin.orm.filter.type.number           prototype Sonata\AdminBundle\Filter\ORM\NumberFilter
sonata.admin.orm.filter.type.string           prototype Sonata\AdminBundle\Filter\ORM\StringFilter
sonata.admin.pool                             container Sonata\AdminBundle\Admin\Pool
sonata.admin.route_loader                     container Sonata\AdminBundle\Route\AdminPoolLoader
sonata.admin.security.handler                 n/a       alias for sonata.admin.security.handler.noop
sonata.admin.security.handler.acl             container Sonata\AdminBundle\Security\Handler\AclSecurityHandler
sonata.admin.security.handler.noop            container Sonata\AdminBundle\Security\Handler\NoopSecurityHandler
sonata.admin.twig.extension                   container Sonata\AdminBundle\Twig\Extension\SonataAdminExtension
sonata.admin.validator.inline                 container Sonata\AdminBundle\Validator\InlineValidator
vido.admin.admin.video                        prototype Vido\AdminBundle\Admin\VideoAdmin

if I try to open something like http://localhost:9999/app_dev.php/admin/vido/admin/video/list It works
but http://localhost:9999/app.php/admin/vido/admin/video/list returns 404 error
Looks like some routing problem, but routins are placed in routing.yml and should be loaded in both environments dev and prod.

any other suggestions? I still have no ideas about what could be problem :(

Solution is php app/console cache:clear --env=prod --no-debug

Was this page helpful?
0 / 5 - 0 ratings