Symfony 2 ScannerException #(64) - symfony

I'm getting following exception in my app/config/config.yml file:
ScannerException while scanning for the next token we had this found
character #(64) that cannot start any token
The line that causes exception:- { resource: #BazaBlogBundle/Resources/config/config.yml }
I think it's compatibility problem. I'm following tutorial for Symfony version 2.0 and I'm using 2.16. Any thoughts?

I think you are missing the double quotes :
- { resource: "#BazaBlogBundle/Resources/config/config.yml" }

Related

Problems with Geoplugin in Symfony 3.4

I am trying to upgrading my existing Symfony 2.8 web site to 3.4.
I have faced and fixed many issues but I am stuck with a Geoplugin issue.
I have updated like the following my AppBundle/Resources/config/services.yml to respect the new YAML directives (thus I have added '' around #variables) :
app.ipgeo:
class: AppBundle\Utils\Geo\Geoplugin
arguments: ['#request', '#doctrine.orm.entity_manager', '#service_container']
scope: request
tags:
- { name: kernel.event_listener, event: kernel.controller, method: onLoad }
But I get a PHP Fatal error when accessing the web site :
AH01071: Got error 'PHP message: PHP Fatal error: Call to a member function getUri() on string in /var/www/vhosts/alpclic-dev.fr/httpdocs/dev.scenes-locales.com/src/AppBundle/Utils/Geo/Geoplugin.php on line 58
PHP message: PHP Fatal error: Call to a member function getUri() on string in
/var/www/vhosts/alpclic-dev.fr/httpdocs/dev.scenes-locales.com/src/AppBundle/Utils/Geo/Geoplugin.php
on line 58\n'
Any idea ?
Of course, it was perfectly working in 2.8 with the following configuration :
app.ipgeo:
class: AppBundle\Utils\Geo\Geoplugin
arguments: [#request, #doctrine.orm.entity_manager, #service_container]
scope: request
tags:
- { name: kernel.event_listener, event: kernel.controller, method: onLoad }
Not so easy and "self-explanatory" !
I had to migrate to 'request_stack' service as mentioned here : How to inject the #request into a service?

Silverstripe 4 error log

How can I log errors to file log in SilverStripe 4?
I mean all errors causing 'Internal server error' info from SS
In SilverStripe it was :
SS_Log::add_writer(new SS_LogFileWriter('/var/log/silverstripe/errors.log'), SS_Log::ERR);
Documentation says that I need to do something like:
SilverStripe\Core\Injector\Injector:
Psr\Log\LoggerInterface:
calls:
LogFileHandler: [ pushHandler, [ %$LogFileHandler ] ]
LogFileHandler:
class: Monolog\Handler\StreamHandler
constructor:
- "../silverstripe.log"
- "info"
I try this but cannot get this to work :(
Try to add to your .env file (https://docs.silverstripe.org/en/4/getting_started/environment_management/) such string:
SS_ERROR_LOG = "silverstripe.log"
To create a custom log try:
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
Then later:
$logger = new Logger("my_name");
$logger->pushHandler(new StreamHandler('./silverstripe-custom.log', Logger::INFO));
$logger->info('hi there');
You should find silverstripe-custom.log in the project root.

Symfony3 404 exception response return with status code 200 instead of 500

I am new in symfony,I have facing one problem in Production Environment after I add kernel.event_subscriber in service.yml. problem is before adding event subscriber in service.yml file It return 500 HTTP_STATUS_CODE & Resource Not Found exception occur with my custom page in twingbuddle That I set, below page it show before add event_subscriber In Service.yml When I go to URL: http://localhost/meopin_2/trunk/web/en/login/ddssssssssss,
Then I add below code in Service.yml
kernel.event_subscriber:
class: AppBundle\EventSubscriber\TokenSubscriber
arguments: ["#security.http_utils","#service_container","#router", {}, {}, {},{}]
tags:
- { name: kernel.event_subscriber, channel: 'kernel' ,event: onKernelController,method: onKernelController}
and make a File Event Describer. Now issue is When I go to Same URL: http://localhost/meopin_2/trunk/web/en/login/ddssssssssss
It Return me Error as a Text Message with HTTP_STATUS_CODE 200, Below response It Return Me Instead of My Previous 404 Page in Production Environment.
What I missing or Wrong So that It return error as a text message in Production Environment ?
Thanks In Advance if Any one help me.

Symfony2 template configuration from routing.yml

When dealing with the Sylius e-commerce bundles I have found what seems to be a way of configurig the template for a route, that I didn't know:
I have tested in a fresh Symfony RC 2.2.0 with vendors installation.
This would be in the routing.yml
_welcome:
pattern: /
defaults:
_controller: AcmeDemoBundle:Welcome:index
_template: AcmeDemoBundle:Welcome:index # added by me
this generates an error:
FatalErrorException: Error: Call to a member function getTemplate() on
a non-object in
.... \vendor\sensio\framework-extra-bundle\Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener.php
line 62
now, in TemplateListener, what we have is:
if (!$configuration = $request->attributes->get('_template')) {
return;
}
if (!$configuration->getTemplate()) {
$guesser = $this->container->get('sensio_framework_extra.view.guesser');
$configuration->setTemplate($guesser->guessTemplateName($controller, $request, $configuration->getEngine()));
}
$configuration is a String, actually the template I put in routing.yml (AcmeDemoBundle:Welcome:index). Checked by adding a var_dump and also inspecting ParameterBag -> get method which is what $request->attributes is.
So. Why TemplateListener is expecting an object? What am I missing? Am I missconfiguring in routing.yml?
This parameter is not available in Symfony itself.
Feature is provided by SyliusResourceBundle and available only in Sylius controllers.
And apparently _template request attribute conflicts with SensioFrameworkExtraBundle, which uses same name to store object.
We have to move those parameters one config node deeper, to avoid such problems in future.
You can keep an eye on the https://github.com/Sylius/SyliusResourceBundle repository, fix should arrive today.

Routing requirements 0

I have a problem with my Symfony2.2 beta routes. (symfony-2-2-0-beta-1)
I use annoations routes like this:
#Route("/form/{id}", defaults={"id"=0}, requirements={"id"="\d+"});
And the error is:
An exception has been thrown during the rendering of a template ("Parameter "id" for route "[...]_form" must match "\d+" ("" given).") in [...]:form.html.twig at line 1.
The line 1 is:
{{ path("[...]_form") }}
I think the route is correct, because I define "id=0" as default.
And in Symfony2.1 the same code works.
Have you tried setting the default in your action and taking it out of the annotation?
/**
* #Route("/form/{id}", name="my_form", requirements={"id"="\d+"});
*/
public function myFunction($id = 0){
...
I believe this is one of the changes in Symfony 2.2 although I haven't tried it yet. http://symfony.com/blog/new-in-symfony-2-2-small-things-matter#defining-default-values-when-using-the-route-annotation
You can try
requirements:
id: \S|\d+

Resources