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
Related
I have created helper file in laravel. I want to use laravel functionalities.
I am not able to use use or namespace template in helper file.
code of helper file.
namespace App\Helpers;
class CommonFunctions {
public static function get_cat() {
}
}
I have linked this helper in config/app.php
When I use namespace in helper file then this error is displaying
Blade file code
Finally I found the issue.
Actually I am migrating site from laravel 5.2 to 5.7 and I was copying the old helper file to new that's why I got this error..
Previously I was using use and namespace together but after adding use statements only I solved the issue.
It might be the issue of namespace is not allowing in helper file, but in every solution and method of creating helper files there is namespace, so, I had never try to remove that line.
But now I got the solution...
Thanks for all who helped me.
Shishil Patel
I guess you have syntaxis error in your helper.
anyways try to execute php artisan config:clear and then fix all errors.
I have done everything the same way and I haven't found any problem.
I'm trying to define some custom config values for my Symfony Flex application (which will be filled with .env values), but all the docs assume I'm using a bundle, like this one: https://symfony.com/doc/current/bundles/extension.html
I have a custom namespace, something like 'Foo\Bar', so I though the Extension class should be called src\DependencyInjection\FooBarExtension.php, but that doesn't work.
Does anyone know how I can load my custom config?
Edit: the following solution worked:
Put config file foo.yaml in config/packages
Put FooExtension.php in src/DependencyInjection
Add following code to Kernel.php
public function build(ContainerBuilder $container)
{
$container->registerExtension(new FooExtension());
parent::build($container);
}
In Symfony 4.1, you should be able to register a new extension in your AppKernel by overriding the build() method. There, you can register your extensions which in turn enable you to parse your own configuration files.
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.
I created a modular system by using laravel 4.1 I have a tree scheme as follows:
app/
app/controllers/
app/modules/
app/modules/modulename/
app/modules/modulename/controllers/
app/modules/modulename/controllers/modulecontroller.php
app/modules/modulename/models/
app/modules/modulename/models/modulemodel.php
What I want to do is to call the model from a controller in app/controllers/ class.
How I can call that module and its model?
Make sure your /app/modules is added to your composer.json file's autoload : classmap and issue composer dump-autoload or php artisan dump-autoload. Then you can just create an instance like new ModuleModel or whatever name you gave your class. Though it's better to pass to your controller by dependency injection. This way your code will be easier to test because you can pass in stub data.
public function __construct(ModuleModel $module_model_instance) {
$this->module_model_instance = $module_model_instance;
}
I'd rather add this as a comment but have insufficient rep.
If everything is correctly autoloaded by composer in the PSR-0 (or 4) section, then you should just be able to reference it using it's namespace?
I sometimes need to run
composer dump-autoload
to refresh the autoloaded files, especially if using vagrant.
Hope this is helpful. I'm not sure if I've fully understood your problem.
I am using CakePHP 2.4.2 and this plugin by predominant.
I want to use TwigView with CakePHP and found that the plugin above is compatible with CakePHP 2.0. Followed all the installation steps, however, getting the Missing View error while executing the script.
My AppController.php
<?php
App::uses('Controller', 'Controller');
class AppController extends Controller {
public $viewClass = 'TwigView.Twig';
}
The view's extention is .tpl, however, even after adding the Plugin it is still looking for .ctp extention.
I have also loaded the plugin in bootstrap.php using
CakePlugin::load('TwigView');
define('TWIG_VIEW_CACHE', APP . 'tmp');
Any Idea what could go wrong.
http://api.cakephp.org/2.4/source-class-Controller.html#209-214
Set the Controller::$ext property in your app controller to "tpl" and your're done.
Searching before asking is also always a good idea, see CakePHP View change extension