I am trying to create sample project in yii but I am having this problem while trying to run my code:
CHttpException
The system is unable to find the requested action "error". (C:\wamp\www\yii\framework\web\CController.php:484)
#0 C:\wamp\www\yii\framework\web\CController.php(271): CController->missingAction('error')
#1 C:\wamp\www\yii\framework\web\CWebApplication.php(276): CController->run('error')
#2 C:\wamp\www\yii\framework\base\CErrorHandler.php(310): CWebApplication->runController('site/error')
#3 C:\wamp\www\yii\framework\base\CErrorHandler.php(183): CErrorHandler->render('error', Array)
#4 C:\wamp\www\yii\framework\base\CErrorHandler.php(108): CErrorHandler->handleException(Object(CHttpException))
#5 C:\wamp\www\yii\framework\base\CApplication.php(713): CErrorHandler->handle(Object(CExceptionEvent))
#6 [internal function]: CApplication->handleException(Object(CHttpException))
#7 {main}
Can anyone tell me the reason ? As I think this is not the problem of my code.
An exception has occurred (most likely due to a bug or misconfiguration) and Yii attempted to run the error handler, which in this case is the error action on the site controller.
The error occurs because you do not have a site controller, or it does not have an error action.
Related
So my route is defined as:
Route::get('dashboard/upgrade/invoice/{code}',[PackageController::class,'invoice'])->name('user.invoice');
The visited url is:
https://examplewebsite.com/dashboard/upgrade/invoice/3SInyM0RwGkKz2vSYsqLxlfsL
now this url sometimes open without any error.
other times, it returns 500 SERVER ERROR
When I checked my laravel.log to see why, I see:
production.ERROR: Index invalid or out of range {"view":{"view":"/home/xx/xx/resources/views/dashboard/upgrade/invoice.blade.php","data":[]},"userId":xx,"exception":"[object] (Spatie\\LaravelIgnition\\Exceptions\\ViewException(code: 0): Index invalid or out of range at /home/fewflyok/xxx/vendor/bacon/bacon-qr-code/src/Encoder/MaskUtil.php:134)
on the blade template, I have the qrcode line called with:
{!! QrCode::color(34, 27, 114)->size(150)->generate($invoice->address ) !!}
Now I want I am not using the bacon-qr-code on this particular blade. I have a different qrCode package (SimpleSoftwareIO) which I already set up on my config/app.
I then discover that the stacktrace traces to the qrcode I am using. So here is an extended log:
[stacktrace]
#0 xx/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php(197): BaconQrCode\\Encoder\\MaskUtil::applyMaskPenaltyRule3()
#1 xxx/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php(244): BaconQrCode\\Encoder\\Encoder::calculateMaskPenalty()
#2 xxx/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php(135): BaconQrCode\\Encoder\\Encoder::chooseMaskPattern()
#3 xxx/vendor/bacon/bacon-qr-code/src/Writer.php(54): BaconQrCode\\Encoder\\Encoder::encode()
.
.
#4 xxx/vendor/simplesoftwareio/simple-qrcode/src/Generator.php(171): BaconQrCode\\Writer->writeString()
#5 xxx/resources/views/dashboard/upgrade/invoice.blade.php(31): SimpleSoftwareIO\\QrCode\\Generator->generate()
.
.
#6 xxx/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(109): require('/home/fewk/...')
#7 xxx/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(110): Illuminate\\Filesystem\\Filesystem::Illuminate\\Filesystem\\{closure}()
#8 xxx/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(58): Illuminate\\Filesystem\\Filesystem->getRequire()
#9 xx/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(61): Illuminate\\View\\Engines\\PhpEngine->evaluatePath()
#10 xxx/vendor/laravel/framework/src/Illuminate/View/View.php(139): Illuminate\\View\\Engines\\CompilerEngine->get()
Have a look at https://github.com/Bacon/BaconQrCode/issues/92
seems it's related to php8.1 opcache and jit=tracing
switching to jit=function helps...
I am creating an API for get user by YII2 user api by user id. If I pass user id then it is working good but If I pass string then I get below error.
<pre>An Error occurred while handling another error:
yii\base\InvalidParamException: Response content must not be an array. in /var/www/html/vendor/yiisoft/yii2/web/Response.php:1020
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/web/Response.php(313): yii\web\Response->prepare()
#1 /var/www/html/vendor/yiisoft/yii2/web/ErrorHandler.php(128): yii\web\Response->send()
#2 /var/www/html/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(yii\web\NotFoundHttpException))
#3 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\NotFoundHttpException))
#4 {main}
Previous exception:
yii\base\InvalidRouteException: Unable to resolve the request: categories/wewqewqe in /var/www/html/vendor/yiisoft/yii2/base/Controller.php:127
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('wewqewqe', Array)
#1 /var/www/html/vendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction('categories/wewq...', Array)
#2 /var/www/html/vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))
#3 /var/www/html/index.php(16): yii\base\Application->run()
#4 {main}
Next yii\web\NotFoundHttpException: Page not found. in /var/www/html/vendor/yiisoft/yii2/web/Application.php:114
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 /var/www/html/index.php(16): yii\base\Application->run()
#2 {main}</pre>
I am using swagger for executing APIs and Endpoint of the API is
users/{id}
Work fine when enter
/users/1
Get error when
/users/asdf
Web.php
'users/<id:\d+>' => 'users/',
I have recently faced same issue and it has been solved by the change in routing in web.php in config folder.
Change your url
users/<id> instead of users/<id:\d+>.
I'm working on a tool which uses Yii version 1.1.13 and after addig new error messages with the addErrormethod, despite it worked fine on the page I used it, it threw a strange, long error message on the index page with an error 500.
Missing argument 1 for CModel::getError(), called in /var/www/html/framework/base/CComponent.php on line 111 and defined (/var/www/html/framework/base/CModel.php:371)
Stack trace:
#0 /var/www/html/protected/models/Testcases.php(132): Testcases->__get()
#1 /var/www/html/protected/views/site/index.php(189): Testcases->search()
#2 /var/www/html/framework/web/CBaseController.php(126): require()
#3 /var/www/html/framework/web/CBaseController.php(95): SiteController->renderInternal()
#4 /var/www/html/framework/web/CController.php(869): SiteController->renderFile()
#5 /var/www/html/framework/web/CController.php(782): SiteController->renderPartial()
#6 /var/www/html/protected/controllers/SiteController.php(295): SiteController->render()
#7 /var/www/html/framework/web/actions/CInlineAction.php(49): SiteController->actionIndex()
#8 /var/www/html/framework/web/CController.php(308): CInlineAction->runWithParams()
#9 /var/www/html/framework/web/CController.php(286): SiteController->runAction()
#10 /var/www/html/framework/web/CController.php(265): SiteController->runActionWithFilters()
#11 /var/www/html/framework/web/CWebApplication.php(282): SiteController->run()
#12 /var/www/html/framework/web/CWebApplication.php(141): CWebApplication->runController()
#13 /var/www/html/framework/base/CApplication.php(184): CWebApplication->processRequest()
#14 /var/www/html/index.php(13): CWebApplication->run()
REQUEST_URI=/index.php
in /var/www/html/protected/models/Testcases.php (132)
in /var/www/html/protected/views/site/index.php (189)
in /var/www/html/protected/controllers/SiteController.php (295)
This bug appeared after generating test cases for my new error message. Then I reverted my modified file from the svn repository as the previous version worked fine, but I still can't get rid of this message.
I added the new errors like this:
if (FieldsQueue::model()->exists("fieldname = 'something'"))
$model->addError('Error', "Something happened");
else if (!isset($_POST['something']))
$model->addError('test',"This is the new error);
else { do something }
Thanks in advance for your helping answers. :)
Hii The definition of addError is
public void addError(string $attribute, string $error)
$attribute Should be your model (db) attribute
In your code
$model->addError('Error', "Something happened");
Error Should be your model attribute
Finally solved, there was a row in the database which caused an error, I still don't know how, and which one was it (I just deleted some I added recently before the bug appeared). It is actually very strange because there wasn't anything about the DB in this error message.
I am newbie with zf2 framework. For example, now I get this error:
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (ZfcUserOverride) could not be initialized.' in F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php:189 Stack trace:
#0 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(163): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))
#1 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(90): Zend\ModuleManager\ModuleManager->loadModule('ZfcUserOverride')
#2 [internal function]: Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
#3 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent))
#4 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('loadModules', Object(Zend\ModuleManager\ModuleEvent), NULL)
#5 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(109): Zend\EventManager\EventManager->trigger('loadModules', Object(Zend\ModuleManager\ModuleManager), Object(Zend\ModuleManager\ModuleEvent))
#6 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(252): Zend\ModuleManager\ModuleManager->loadModules()
#7 F:\Server\domains\zf2-skeleton\public\index.php(17): Zend\Mvc\Application::init(Array)
#8 {main} thrown in F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php on line 189
I formatted it manually, so you can read correct error.
It is hard to do it all time I get some error. How I can make zf2 to output such errors correctly?
I need something like this:
The ZendSkeletonApplication comes with a template that reports errors in a readable format. If you install the ZendSkeletonApplication and build your application off of it, you’ll benefit from this template and other conveniences. Alternatively, you can use just the standard error template or create your own.
I have the following appearing in my log files and being a new comer to Laravel, I'm not sure where to start debugging. Any assistance would be appreciated.
[2013-12-23 01:04:41] log.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /home/ulti/laravel4/bootstrap/compiled.php:5125
Stack trace:
#0 /home/ulti/laravel4/bootstrap/compiled.php(4970): Illuminate\Routing\Router->handleRoutingException(Object(Symfony\Component\Routing\Exception\ResourceNotFoundException))
#1 /home/ulti/laravel4/bootstrap/compiled.php(4958): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /home/ulti/laravel4/bootstrap/compiled.php(534): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#3 /home/ulti/laravel4/bootstrap/compiled.php(521): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#4 /home/ulti/public_html/index.php(49): Illuminate\Foundation\Application->run()
#5 {main} [] []
All this means is that you visited a route that doesn't exist.
This means you have an invalid route. This is saying "Hey this page doesn't exist!". The page might exist but due to how routes are defined, and that controllers aren't routed automatically, it may not function as you expect. Can you post the code that has your routes, and also the URL you're trying to go to on site? That would be a start to help you with debugging! :)