I am creating a custom page /devis
So I have made a simple controller like so:
<?php
class DevisControllerCore extends FrontController
{
public $php_self = 'devis';
public function initContent()
{
$this->setTemplate('devis/devis');
parent::initContent();
}
}
I have been created devis.tpl in my themes/myTheme/templates/devis/ folder
I have been added the friendly url to reach the page (/devis)
My problem is : When I reach the page
Fatal error: Uncaught Error: Class 'DevisController' not found in /var/www/vhosts/example.com/httpdocs/preprod_online/classes/controller/Controller.php:208 Stack trace: #0 /var/www/vhosts/example.com/httpdocs/preprod_online/classes/Dispatcher.php(503): ControllerCore::getController('DevisController') #1 /var/www/vhosts/example.com/httpdocs/preprod_online/index.php(28): DispatcherCore->dispatch() #2 {main} thrown in /var/www/vhosts/example.com/httpdocs/preprod_online/classes/controller/Controller.php on line 208
The solution is to check if the name of the file is correct
structure
/controllers/front/NameController.php
and then (even if it was correctly named) Clear the cache in prestashop back office
parameters > Performances > Clear cache
Related
I faced a problem - I can’t render a custom view for Laravel 5.8 404 error.
I have a resources/views/errors/404.blade.php file that I want to display to visitors.
According to Laravel documentation (https://laravel.com/docs/5.8/errors#custom-http-error-pages) nothing more is needed, a custom view for 404 errors should be displayed without problems.
I have service provider, here is its boot method:
public function boot ()
{
abort (404); // if i generate a 404 error from here, everything works fine and 404.blade.php is displayed without problems
View :: composer (['*'], function ($view) {
abort (404); // but if i generate a 404 error from here, it displays NotFoundHttpException
});
It turns out that calling abort (404) from an anonymous function does not allow you to display a custom view on a 404 error ???
UPDATE
if I generate a 404 error from an anonymous function, I get this exception:
Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Uncaught Symfony\Component\HttpKernel\Exception\NotFoundHttpException in C:\Downloads\OSPanel\domains\site.com\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:992
Stack trace:
#0 C:\Downloads\OSPanel\domains\site.com\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php(46): Illuminate\Foundation\Application->abort(404, '', Array)
#1 C:\Downloads\OSPanel\domains\site.com\app\Providers\SiteViewServiceProvider.php(70): abort(404)
#2 C:\Downloads\OSPanel\domains\site.com\app\Providers\SiteViewServiceProvider.php(42): App\Providers\SiteViewServiceProvider->getAntiLocaleURL()
#3 C:\Downloads\OSPanel\domains\site.com\vendor\laravel\framework\src\Illuminate\View\Concerns\ManagesEvents.php(164): App\Providers\SiteViewServiceProvider->App\Providers\{closure}(Object(Illuminate\View\View))
#4 C:\Downloads\OSPanel\domains\site.com\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php(344): Illuminate\View\Factory->Illuminate\View\Concerns\{closure}('composing: erro...', Array)
#5 C:\Do"
Stacktrace:
#0 Symfony\Component\Debug\Exception\FatalErrorException in C:\Downloads\OSPanel\domains\site.com\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:992
I am getting following error when I try to use Illuminate\Http\Request in my class.
Error:
PHP Fatal error: Uncaught RuntimeException: A facade root has not been set. in /home/sasha/Documents/OffProjects/vetnearme/vetnearme/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218
Stack trace:
#0 /home/sasha/Documents/OffProjects/vetnearme/vetnearme/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(396): Illuminate\Support\Facades\Facade::__callStatic('replaceNamespac...', Array)
#1 /home/sasha/Documents/OffProjects/vetnearme/vetnearme/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(373): Illuminate\Foundation\Exceptions\Handler->registerErrorViewPaths()
#2 /home/sasha/Documents/OffProjects/vetnearme/vetnearme/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(288): Illuminate\Foundation\Exceptions\Handler->renderHttpException(Object(Symfony\Component\HttpKernel\Exception\HttpException))
#3 /home/sasha/Documents/OffProjects/vetnearme/vetnearme/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(187): Illumina in /home/sasha/Documents/OffProjects/vetnearme/vetnearme/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 218
The class in question:
namespace App\App\Components;
use Illuminate\Http\Request;
/**
* This class will be used to build menu for admin panel based on the user role
*/
class AdminPanelMenu {
static function menu(Request $request){
$user = $request->user();
if($user->hasRole['super_admin'])
return self::superAdmin();
if($user->hasRole['admin'])
return self::admin();
if($user->hasRole['user'])
return self::user();
return [];
}
private static function superAdmin()
{
return [
'MAIN NAVIGATION',
];
}
private static function admin()
{
return [
'MAIN NAVIGATION',
];
}
private static function user()
{
return [
'MAIN NAVIGATION',
];
}
}
What am I doing wrong here?
You need to create a new app container and then bind it to the Facade.
use \Illuminate\Container\Container as Container;
use \Illuminate\Support\Facades\Facade as Facade;
/**
* Setup a new app instance container
*
* #var Illuminate\Container\Container
*/
$app = new Container();
$app->singleton('app', 'Illuminate\Container\Container');
/**
* Set $app as FacadeApplication handler
*/
Facade::setFacadeApplication($app);
in lumen:
bootstrap/app.php
$app->withFacades();
Good luck!
I know this is old but maybe it will help someone. I ran into this problem after I was fiddling with my app/config.php file. I added some options and accidentally put a semi-colon instead of a comma after it.
I had:
'vapid_public_key' => env('VAPID_PUBLIC_KEY'); <--- offending semi-colon
'vapid_private_key' => env('VAPID_PRIVATE_KEY'),
Changed it to the proper comma and everything works as expected.
Really late but hopefully can help someone else. I found the easiest solution to this error was just to change the route (ie from /post to /posts) of the page that this error appears. And don't forget to change anywhere that has direct links to it.
I think the problem is that Laravel is confusing scope resolution to facade error. check your code so make sure you do not have any static variable not existing in a class. E.g if you have a PHP class like;
<?php
class StaticExample
{
public const EXAM = 'exam';
}
?>
then you try to call a non-existing const StaticExample::EXAMS. Laravel will give you the above error which makes no sense because it's very difficult to trace. No error in the logs and you're lost.
My solution is to use an editor like PHPStorm that will point out your development errors. Another way is that you should check your scope resolutions very well.
I am facing a problem with CodeIgniter framework in PhpStorm.
I have created a controller as home.php with a public function test. And I've created a view page as mytest.
In browser when I type http://localhost/mvc/index.php/home/test/
the page is not loading it shows
"404 page not found".
What might be the problem?
Using XAMPP and CodeIgniter 2.1.0
Check your class name,class name should be same as file name,which version of ci are you using?
Controller name : Home.php
Method / Function : test()
View : mytest.php
class Home extends CI_Controller
{
public function test()
{
$this->load->view('mytest');
}
}
Just installed Product Accessories on Magento ver. 1.8.0.0
And my whole website went on fatal errors.
Fatal error: Call to a member function getCollection() on a non-object
Fatal error: Call to a member function setStoreId() on a non-object
Fatal error: Class 'Anais_Accessories_Model_Product'
What do I need to do to get the module running smooth? I can't find an other module that does the same like this one.
Your Model file name should be like this-->> AnaisAccessories.php. Rename all the classes in the Model folder start with the Uppercase and rest should be lowercase as AnaisAccessories. As you can see you've error in class 'Anais_Accessories_Model_Product'.
Make sure file ../Model/AnaisAccessories.php should contain below code. Make appropriate change according to your Module.
class Anais_Accessories_Model_Accessories extends Mage_Core_Model_Abstract
{
public function _construct()
{
parent::_construct();
$this->_init('accessories/accessories');
}
}
I try to start Flexigrid into Codeigniter.
I download demo files from here http://gembelzillonmendonk.wordpress.com/2010/06/28/flexigrid-and-codeigniter-with-advanced-searching-with-example/
but i wrong to set up something:
Instruction from site:
extract .rar to CI folder**
open your controller (ie: CI_Folder\system\application\controllers\flexigrid.php)**
configure flexigrid helper, and customize variable $colModel, example:**
code example
What I did:
I installed correctly CodeIgniter (copy and paste inside htdocs - xampp)
I created a database called 'country' and import sql file inside demo.
I copied correctly files an folders from demo files to my CI folder (called grocery-crud-demo).
But when I type on firefox http://localhost/grocery-crud-demo/index.php/flexigrid/index I have this error
Fatal error: Class 'Controller' not found in C:\xampp\htdocs\grocery-crud-demo\application\controllers\flexigrid.php on line 2
A PHP Error was encountered
Severity: Error
Message: Class 'Controller' not found
Filename: controllers/flexigrid.php
Line Number: 2
Backtrace:
I read instruction also from here: http://roadmyapps.toile-libre.org/index.php/flexigrid/examplebut I don't understand which code exactly I must have into flexigrid.php
I don't understand how configure flexigrid helper, and customize variable $colModel.
I need exact code into files. Have you idea?
I find CodeIgniter 1.7.3 -- I repeat steps -- new error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Ajax_model::$db
Filename: models/ajax_model.php
Line Number: 34
Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\grocery-crud-demo\system\application\models\ajax_model.php on line 34
Code of ajax_model.php is this: http://pastebin.com/P3KawC7S
Probably you are using newer version of CI than one on tutorial.
As I can see tutorial is written for 1.7.2 version.
Try to change
class Someclass extends Controller
{
public function someclass()
{
}
public function index()
{
//etc, etc
}
}
with
class Someclass extends Controller
{
public function __construct()
{
parent::__construct()
{
}
}
public function index()
{
//etc, etc
}
}
Also, for models too. Like
public function Ajax_model()
{
parent::Model();
$this->CI =& get_instance();
}
should be
public function __construct()
{
parent::__construct();
$this->CI =& get_instance();
}
Try that way.
Spot those differences. Those should change in every controller and model respectivelly. Follow this link for upgrading your app.
If fail again, see the CodeIgniter documentation about upgrading versions.