ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58 - php

I recently started learning symfony 2.8 and trying to set up my 1st page on local host. However after configuring my bundle based on this tutorial: https://www.youtube.com/watch?v=S9aQxvEAdcE&list=PLp9j56Yo8a6aWJhLyggonvP7b8vIcYn5Q&index=3
i get this error :
ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58:
The service "doctrine.orm.layout_entity_manager" has a dependency on a non-existent service "doctrine.orm.quote_strategy.layout".
when trying to open my page with adress localhost/st/web/app_dev.php
The reason I am asking this is that couldnt find anything about this particular problem and have no idea what these services is about. If anyone have any clue what I am doing wrong or why this error occurs please share those with me. I am not adding any code because I am not quite sure which files could be the reason of this error. Thanks in advance
EDITED :
I am creating new symfony project using php storm located in C:\wamp64\www\st (enabled symfony plugin and command line tool)
then generating a bundle called MainBundle
I rename DefaultController.php in MainBundle/Controller to MainController.php and change class within it to MainController.
Then rename default folder in app/Resources/views to layout, as well as base.html.twig to layout.html.twig
Then filling a twig files with boostrap template
Then change MainController.php into this :
<?php
namespace MainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class MainController extends Controller
{
/**
* #Route ("/", name="home")
*/
public function indexAction()
{
return $this->render('MainBundle:Default:home.html.twig');
}
}
then in src/Resource/views/Default change index.html.twig into home.html.twig
src/MainBundle/Resources/config/routing.yml fill like this :
main:
resource: "#MainBundle/Controller/MainController.php"
prefix: /
type: annotation
Adding github project link https://github.com/marras1/st

Ok so I am not quite sure what did the magic, but i found this idea here: Symfony2 post-update-cmd gives "An error occurred when generating the bootstrap file"
to remove the /bin and /vendor folders of your project.Then make a composer install (or php composer.phar install if your didn't install composer). In addition i ran php composer.phar update doctrine/mongodb-odm doctrine/mongodb-odm-bundle and the whole system seems working just fine for now.

Related

Laravel package development

I am trying to develop a Laravel package with a helper function, which returns a view. I have uploaded on GitHub already https://github.com/faisalahsan/laravel-breadcrums. When I install it through Packagist https://packagist.org/packages/faisalahsanse/laravel-breadcrums, it installs successfully, but when I register it in the provider array in my app.php as Faisalahsanse\Breadcrums\BreadcumsServiceProvider::class,. It gives the following error:
Class 'Faisalahsanse\Breadcrums\BreadcumsServiceProvider' not found
I don't know where I am getting wrong.
Any suggestions?
Your namespace is wrong https://github.com/faisalahsan/laravel-breadcrums/blob/master/src/BreadcumsServiceProvider.php#L2
It should be Faisalahsan\LaravelBreadcrums. As this namespace you are adding in the composer.json file in psr-4 autoload.
Also your provider to add will be Faisalahsan\Breadcrums\BreadcumsServiceProvider::class

Symfony not overriding bundle view

I have been following the Symfony docs intending to override the Sylius Web Bundle layout.html.twig using inheritance.
The bundle file is at
/vendor/sylius/sylius/src/Sylius/Bundle/WebBundle/Resources/views/Frontend/layout.html.twig
I've placed a new file at
/src/AppBundle/Resources/views/Frontend/layout.html.twig
I have also updated the file at:
/src/AppBundle/AppBundle.php
to inherit the relevant bundle
<?php
namespace AppBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class AppBundle extends Bundle
{
public function getParent()
{
return 'SyliusWebBundle';
}
}
But the page stays the same. If I remove the original layout.html.twig, Symfony says there it cannot find the file. It never attempts to find my new file.
Does this configuration look correct? Is there a common misconfiguration which could be preventing this? Stepping through the debugger I can see that the getParent() function is being hit, but is there any other way I could debug this problem?
Very likely it is just cache.
The code you provided is correct, and it works for me it the exact same config.
so
> php app/console cache:clear
should be all that is needed
One other silly thing that it could be .. did you added your appbundle to appKernel.php ??
Try to place the template at:
app/Resources/SyliusWebBundle/views/layout.html.twig

ReflectionException Laravel 5.1

I have developed an application with Laravel, version 5.1, using homestead to test.
When I place it on the production server, I get this error that I can't replicate on the local machine:
ReflectionException in Container.php line 736
Class MyMultiSelect does not exist
This class is a sleeping-owl Custom Form Item
http://sleeping-owl.github.io/en/Form_Elements/Custom_Form_Elements.html
I checked for:
namespace errors / conflicts
I even placed the class in the global namespace
tried to load the file containing the class in composer.json
Filename: MyMultiSelect.php
Class: MyMultiSelect
namespace: Global so to access it \MyMultiSelect
admin/bootstrap.php
FormItem::register('myMultiSelect', \MyMultiSelect::class);
Can anyone help me?
Run composer dump-autoload on your server. This will rebuild the autoloader cache, that stores paths to classes. If your paths are different locally and on the server, this could help.

Generating Bundle in Symfony

Can't find a solution for this on stack.
I'm using ubuntu server,
$php app/console generate:bundle --namespace=WMDN/FirstBundle --format=yml
goes fine until :
Generating the bundle code: OK
Checking that the bundle is autoloaded: FAILED
Confirm automatic update of your Kernel [yes]? yes
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]? yes
Importing the bundle routing resource: OK
The command was not able to configure everything automatically.
You must do the following changes manually.
- Edit the composer.json file and register the bundle
namespace in the "autoload" section:
I thought it was permissions, and set the whole dir to 775 and made sure owner was good.
I thought it was outdated bug for symfony and deleted whole dir, and got 2.4.4
I'm following a tutorial and their bundle generates just fine and I'd like mine to do it as well.
Why can it not autoload? My Namespace should be good to use. I cannot figure it out.
I have composer installed.
Following this tutorial series : http://www.youtube.com/watch?v=GIcY5YYfZ14 and I'd really like to get my first bundle created so I may continue.
In conclusion, what are the reasons a bundle would fail autoload?
Per to comments, solution was to set the --src parameter correctly.

registering Bundle to symfony kernel

Instead of Using composer I download zip file of a bundle and extract this bundle to my symfony project. I change all relative address for example I change all namespace Trsteel\CkeditorBundle; to namespace Acme\TrsteelCkeditorBundle; for doing this I searched the downloaded directory for every Trsteel\CkeditorBundle and change all of them to Acme\TrsteelCkeditorBundle now when I want to use this Bundle on my project I register this bundle to my appKernel.php of symfony project But I reached this error
Error: Class 'Acme\TrsteelCkeditorBundle\TrsteelCkeditorBundle' not found in /Users/kingkong/Documents/workspace/dev/Project/SRC/app/AppKernel.php line 45
File names should be the same as namespace structure, capitalization may be an issue, so check that.
You may want to place the bundle in this way - "Acme\Trsteel\CkeditorBundle\CkeditorBundle"
Check whether you have actually changed the folder structure from Trsteel\CkeditorBundle to Acme\TrsteelCkeditorBundle. And also check your routing files as well. (I assume you have done the routing part as the error won't say that it can't get to that location.)
Cheers!

Categories