non-existing parameter for 'sonata.page.admin.block' - php

I am nearly finished with installing most of the Sonata bundles in Symfony CMF. For now. my final step is finishing with the Sonata PageBundle. I installed all needed dependencies and needed bundles, I changed several config or routing files from app/config using this manual (http://sonata-project.org/bundles/page/master/doc/reference/installation.html).
The problem appears when I want to to do the 'last' step;
php app/console sonata:easy-extends:generate SonataPageBundle
I receive this error:
{ParameterNotFoundException: The service "sonata.page.admin.block" has a dependency on a non-existent parameter "sonata.block.container.types". Did you mean this: "sonata.page.block.container.class"?}
Okay, it is obvious that a dependency parameter is missing, but I am unable to pinpoint the exact problem.
My sonata_page & sonata_block from app/config/config.php;
sonata_page:
multisite: host
use_streamed_response: true # set the value to false in debug mode or if the reverse proxy does not handle streamed response
ignore_route_patterns:
- ^(.*)admin(.*) # ignore admin route, ie route containing 'admin'
- ^_(.*) # ignore symfony routes
ignore_routes:
- sonata_page_cache_esi
- sonata_page_cache_ssi
- sonata_page_js_sync_cache
- sonata_page_js_async_cache
- sonata_cache_esi
- sonata_cache_ssi
- sonata_cache_js_async
- sonata_cache_js_sync
- sonata_cache_apc
ignore_uri_patterns:
- ^/admin\/ # ignore admin route, ie route containing 'admin'
page_defaults:
homepage: {decorate: false} # disable decoration for homepage, key - is a page route
default_template: default # template key from templates section, used as default for pages
templates:
default: { path: 'SonataPageBundle::layout.html.twig', name: 'default' }
2columns: { path: 'SonataPageBundle::2columns_layout.html.twig', name: '2 columns layout' }
# manage the http errors
catch_exceptions:
not_found: [404] # render 404 page with "not_found" key (name generated: _page_internal_error_{key})
fatal: [500] # so you can use the same page for different http errors or specify specific page for each error
sonata_block:
# context_manager: sonata.page.block.context_manager
default_contexts: [cms]
blocks:
sonata.admin.block.admin_list:
contexts: [admin]
#sonata.admin_doctrine_orm.block.audit:
# contexts: [admin]
sonata.block.service.text:
sonata.block.service.rss:
sonata.page.block.container:
sonata.page.block.children_pages:
There is a similar question here on SO, but unanswered for 4 months, Google doesn't have any info (that I was able to find) on this issue.
If someone can point out what is going wrong and where, I would love to hear it..

There is no support for SonataPageBundle by the CMF project yet. So I guess the "symfony-cmf" tag is incorrect?

Related

Get API Platform documentation running in an existing Symfony 3.4 appliation

Following the advice from this thread, I ran the following in my existing Symfony 3.4 application's home directory:
composer require api-platform/core v2.2
... after which composer spit out a bunch of green messages confirming successful installation.
However, when I visit http://localhost:8443/ as suggested here, I get 'can't establish a connection'.
My Symfony app is still running normally when I go to http://localhost. Are there additional steps required to get the API Platform documentation running?
(For Symfony2/3)
Use this package with composer:
composer require api-platform/core
Configure the bundle manually in AppKernel.php:
$bundles = [
// [...]
new ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle(),
];
Add this in your app/config/routing.yml
api:
resource: '.'
type: 'api_platform'
prefix: '/api' # Optional
If needed, add your specific configuration in app/config/config.yml
api_platform:
title: 'specific name'
(complete configuration https://api-platform.com/docs/core/configuration/)
I hope it will help.

Symfony 4: You have requested a non-existent parameter "locale"

When I enable the 'dev' mode in my Symfony 4 app (that is already online in a shared hosting service) it shows this message:
(1/1) ParameterNotFoundException
You have requested a non-existent parameter "locale".
in ParameterBag.php (line 100)
at ParameterBag->get('locale')
in EnvPlaceholderParameterBag.php (line 57)
at EnvPlaceholderParameterBag->get('locale')
in ParameterBag.php (line 216)
at ParameterBag->resolveString('%locale%', array('locale' => true))
in ParameterBag.php (line 187)
...
and does not allow to debug the app. My config/services.yml code is as default:
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: 'en'
services:
# default configuration for Services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your Services.
autoconfigure: true # Automatically registers your Services as commands, event subscribers, etc.
public: false # Allows optimizing the container by removing unused Services; this also means
# fetching Services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
...
Please, someone can help me to fix this error.
Had the same problem during the fresh symfony 4.3 + sonata admin bundle installation.
As a solution I added locale parameter:
// /config/services.yaml
parameters:
locale: 'en'
While I am not a Symphony expert the documentation appears to allow anything in the parameters section, but it does mention also defining the values in the .env.dist file as well for them to be used here.
http://symfony.com/doc/current/best_practices/configuration.html#canonical-parameters
When upgrading from symfony 4.2 to symfony 4.4 I also got this error when composer commands.
This parameter seems so be used in config/packages/translation.yml.
Updating the symfony/translation recipe which no longer refers to %locale% but hardcode 'en' solves the problem for me.
Simply run composer recipes:install symfony/translation --force -v

Symfony 2: "No route found for "GET /" - error on fresh installation

I am trying to begin my education of symfony 2 and started with it's tutorial. One of first things I tried was to install symfony 2 and configure it.
When I try to access http://127.0.0.1:8000/, I am getting an incomplete site with the following error:
ERROR - Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /"" at /home/spectator/webprojects/cls/app/cache/dev/classes.php line 2059
Things I have tried so far:
clearing cache (php app/console cache:clear --env=prod --no-debug)
recursively changing permissions to folder cls (symfony 2 folder) to
775 and even 777 (for diagnostics purposes)
adding "/" route to routing.yml and routing_dev.yml
reinstalling and
re-chmod symfony 2.
Try http://localhost:8000/app/example
Fresh installation has no routes for the root path "/"
first you need to set a default route
edit the routing.yml
app/config/routing.yml
app:
resource: #AppBundle/Controller/ # bundle name / Controller name
type: annotation # type of routing or
# app/config/routing.yml # file routing
app:
resource: #AppBundle/Controller/
prefix: /
you can learn more in http://symfony.com/doc/current/book/routing.html
The default installation does not come with a default route for "/".
The example controller only defines a route of
#Route("/app/example", name="homepage")
In the past, a fresh Symfony installation also included some simple demo code to learn how does the framework work. A few months ago we decided to change this behavior by the following:
A fresh Symfony installation no longer contains any demo code.
A new "Symfony Demo Application" has been published for people learning the framework (read more about this demo application).
If you use the Symfony Installer, you should do the following:
When learning Symfony, execute the symfony demo command
When creating a new Symfony project, execute the symfony new my_project command
I had the same problem. Just add <?php in the top of the file. Looks like if we don't specify it s

Symfony 2.4 : Knp paginator Bundle Installation issue

I got this error while I configured Knp paginator Bundle with Symfony 2.4
ERROR :
ClassNotFoundException: Attempted to load class "KnpPaginatorBundle" from namespace "Knp\Bundle\PaginatorBundle" in D:\Projects\wamp\www\Stutorial\app\AppKernel.php line 29. Do you need to "use" it from another namespace?
I followed this steps to install Knp paginator Bundle.
# Install Knp components
git clone git://github.com/KnpLabs/knp-components.git vendor/knp-components
# Install knp paginator bundle
git clone git://github.com/KnpLabs/KnpPaginatorBundle.git vendor/bundles/Knp/Bundle/PaginatorBundle
My config.yml file:
knp_paginator:
page_range: 5 # default page range used in pagination control
default_options:
page_name: page # page query parameter name
sort_field_name: sort # sort field query parameter name
sort_direction_name: direction # sort direction query parameter name
distinct: true # ensure distinct results, useful when ORM queries are using GROUP BY statements
template:
pagination: KnpPaginatorBundle:Pagination:sliding.html.twig # sliding pagination controls template
sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template
I added two lines in my autoload_namespaces.php
'Knp\\Component' => array($vendorDir.'/knp-components/src'),
'Knp\\Bundle' => array($vendorDir.'/bundles'),
And this line to AppKernel.php file
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
Move your plugin folder to vendor/knplabs/knp-paginator-bundle/, so now the real path would be: vendor/knplabs/knp-paginator-bundle/Knp/Bundle/PaginatorBundle/.

request.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /"

I have installed Symfony2, after fixing the file permissions, I can access the dev environment from my browser by pointing it to:
http://localhost/app_dev.php
However, when I try to access the production environment by pointing the browser to http://localhost, I get the following exception (from app/logs/prod.log):
[2012-08-13 11:30:03] request.ERROR:
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route
found for "GET /" (uncaught exc eption) at
/path/to/frameworks/Symfony2/app/cache/prod/classes.php line 4584 []
[]
I then checked the available routes for the prod environment from the command line. here is the result of that investigation.
root#yourbox:~/path/to/frameworks/Symfony2$ php app/console
router:debug -e=prod [router] Current routes Name Method Pattern
Incredibly, it shows that there are no routes defined for this environment (I didn't believe the error message - which essentially said the same thing).
So, my conclusion is this: out of the box installation of Symfony2, and the production environment has no default routes - is this true, or have I made a mistake somewhere?
More importantly, how do I fix this?. In SF1.x, it was straight forward to switch from dev to prod and vice versa. How do I view the AcmeDemo app for example, in a prod environment. ?
[[UPDATE]]
After feedback from thecatontheflat, I added a simple test route to my routing.yml file. The contents of app/config/routing.yml are now:
_welcome2:
pattern: /test
defaults: { _controller: AcmeDemoBundle:Welcome:index }
When I try http://localhost/test in the browser, I get the same 404 error. When I debug the routes available at the console, I get the following output:
root#yourbox:~/path/to/frameworks/Symfony2$ php app/console router:debug -e=prod
[router] Current routes
Name Method Pattern
_welcome2 ANY /test
I had the exact same problem!!
Symfony2 has two generic routing files called:
app/config/routing.yml and app/config/routing_dev.yml
However, it also has a bundle specific routing file in each bundle. The standard procedure is to define all of your bundle routes in your bundle routing.yml file then reference this from the main routing.yml file by adding:
YourbundlenameMainBundle:
resource: "#YourbundlenameMainBundle/Resources/config/routing.yml"
prefix: /
This is what I had and I was still getting the error. But then I read the error more closely... no route found for GET / .... then I checked my routing_dev.yml file and of course it had a route for / from the Acme demo bundle _welcome route. This is why it works for the dev version but not the prod version!
Solution:
Add a route for / to either your routing.yml global file or your routing.yml bundle file by adding the following:
_welcome:
pattern: /
defaults: { _controller: YourbundlenameMainBundle:Default:index }
you can change index to some other route if your welcome page is not index
After you make sure you have your / route defined in any of your routing.yml
_welcome:
pattern: /
defaults: { _controller: YourbundlenameMainBundle:Default:index }
clear your prod environment cache!
app/console cache:clear --env=prod
I had the exact same problem. And it was caused because of a missing bundel in the AppKernel.php.
A little late but you might try to change this line in the web/app.php:
$kernel = new AppKernel('prod', false);
to:
$kernel = new AppKernel('prod', true);
That will enable debugging and you should be able to find your problem. When fixed you will ofcorse need to change it back to false ;).
Hope this helps.

Categories