Gii tool with Yii2.0.45 and php 7.4.29

I have a challenge accessing my newly created CRUD files-the views and this has occurred after i upgraded the Yii2.0.14 to Yii2.0.45. all the new files produces an error of “Not Found (#404)” with or with setting pretty URL.

The previously created View files are accessible without any issue.

I am currently working with Yii-Advanced project with windows 10 in development.

Missing use app\models\Users ?

If not, post more info.

Thanks tri, the problem still persists. this is the error log.
yii\base\InvalidRouteException: Unable to resolve the request “pharmacy/index”. in C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\base\Module.php:561
Stack trace:
#0 C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction(‘pharmacy/index’, Array)
#1 C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\base\Application.php(384): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 C:\xampp\htdocs\Medi\backend\web\index.php(17): yii\base\Application->run()
#3 {main}

Next yii\web\NotFoundHttpException: Page not found. in C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\web\Application.php:115
Stack trace:
#0 C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\base\Application.php(384): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 C:\xampp\htdocs\Medi\backend\web\index.php(17): yii\base\Application->run()
#2 {main}

I am not sure whether this will give more insight to the problem.I have gone through many posts but invain. Thanks

Do you have PharmacyController in backend/controllers?
Elsewhere?

It is in the backend/controllers.This is after generating it from the Gii and i also specified the namespace as backend/models for the model class.

Any resemblance to this discussion?

Nope… my view folder -pharmacy has the default index.php generated by the Gii tool and do not contain code that has urlCreator , actually i had gone through this post /discussion at some point and there are abit different.
Thanks alot… could i share my index.php file

I am just wondering whether may be my configurations/ extensions on composer.json has an effect on the current problem on this post/discussion. Please find the attached error log plus the composer.json files.
…error log…
yii\base\InvalidRouteException: Unable to resolve the request “pharmacy/index”. in C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\base\Module.php:561
Stack trace:
#0 C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction(‘pharmacy/index’, Array)
#1 C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\base\Application.php(384): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 C:\xampp\htdocs\Medi\backend\web\index.php(17): yii\base\Application->run()
#3 {main}

Next yii\web\NotFoundHttpException: Page not found. in C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\web\Application.php:115
Stack trace:
#0 C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\base\Application.php(384): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 C:\xampp\htdocs\Medi\backend\web\index.php(17): yii\base\Application->run()
#2 {main}

…composer.json…
{
“name”: “yiisoft/yii2-app-advanced”,
“description”: “Yii 2 Advanced Project Template”,
“keywords”: [“yii2”, “framework”, “advanced”, “project template”],
“homepage”: “http://www.yiiframework.com/”,
“type”: “project”,
“license”: “BSD-3-Clause”,
“support”: {
“issues”: “Issues · yiisoft/yii2 · GitHub”,
“forum”: “Yii Framework Forum”,
“wiki”: “http://www.yiiframework.com/wiki/”,
“irc”: “irc://irc.freenode.net/yii”,
“source”: “https://github.com/yiisoft/yii2
},
“minimum-stability”: “stable”,
“require”: {
“php”: “>=5.6.0”,
“yiisoft/yii2”: “~2.0.45”,
“yiisoft/yii2-bootstrap”: “~2.0.0”,
“yiisoft/yii2-swiftmailer”: “~2.0.0 || ~2.1.0”,
“dmstr/yii2-adminlte-asset”: “^2.1”,
“wbraganca/yii2-dynamicform”: “",
“wbraganca/yii2-selectivity”: “^2.0”,
“2amigos/yii2-date-picker-widget”: “~1.0”,
“kartik-v/yii2-widget-select2”: "
”,
“2amigos/yii2-ckeditor-widget”: “",
“mpdf/mpdf”: “^8.0”,
“yii2assets/yii2-printthis”: “^1.0”,
“koolreport/yii2”: “^1.0”,
“koolreport/core”: “^5.1”,
“kartik-v/yii2-export”: "
”,
“kartik-v/yii2-mpdf”: “*”,
“kartik-v/yii2-grid”:"@dev"
},
“require-dev”: {
“yiisoft/yii2-debug”: “~2.1.0”,
“yiisoft/yii2-gii”: “~2.1.0”,
“yiisoft/yii2-faker”: “~2.0.0”,
“codeception/codeception”: “^4.0”,
“codeception/module-asserts”: “^1.0”,
“codeception/module-yii2”: “^1.0”,
“codeception/module-filesystem”: “^1.0”,
“codeception/verify”: “~0.5.0 || ~1.1.0”,
“symfony/browser-kit”: “>=2.7 <=4.2.4”
},
“config”: {
“process-timeout”: 1800,
“fxp-asset”: {
“enabled”: false
},
“allow-plugins”: {
“yiisoft/yii2-composer”: true
}
},
“repositories”: [
{
“type”: “composer”,
“url”: “https://asset-packagist.org
}
]
}

  1. Are you using Basic or Advanced template?
  2. What URL are you typing on browser?
  3. Is there any other URL that is working?

@ Stefano , The project is a advanced template,The URLs are not pretty ,though i also changed them to pretty URL but still failed,The URLs that are working are those that i created before i upgraded Yii2 from version 2.0.14 to 2.0.45.

Thanks for your questions.

Since I cannot see the URLs it is hard to suggest anything. If you are concerned with domain name then just use example.com

Sorry for that, this is the URL that is inaccessible http://localhost/medi/backend/web/index.php?r=pharmacy%2Findex.

1 Like

No worries!
Can you post your urlManager configuration

This is the configuration that i had used earlier, though i deactivated hence the current URLs are not pretty…

‘urlManager’ => [
‘enablePrettyUrl’ => true,
‘showScriptName’ => false,
‘rules’ => [
‘’ => ‘site/index’,
controller:\w+/action:\w+/’ => ‘/’,
],
],

Have you enabled the Yii Debug Toolbar ? What does that tell you about the server state, paths, url manager, exception error details etc.

If existing views are working, and all the newly generated code appears the same, are you sure that Gii built the view files in the correct location. By default the Gii tool can sometimes place view files in the project root.

If you begin to re-generate existing views using Gii, you should be able to compare changes without actually generating new files. What does this show you ?

Remove the rules

[
    'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => []
    ]
]

And since the URL is set to pretty try again a pretty URL and post back results

404 means controller/action are not found. So he have something to fix even before thinking in terms of views

@robdlyon Thanks for reaching out…The Yii Debug is enabled and below is the the contents of the error log,
The existing views are working well, the newly created onces are placed on the right paths/folders …since i am using advanced project template… the namespace as backend/models for the model class. backend/controllers for the controller and once while generating Gii prompts if there exists a similar object and whether to override.So i have do this several times but invain,i have also made sure that i stick to the naming conventions of the controllers in Yii2 since it handle capital letters inside the controller name differently.
Thanks .

below is the error log
yii\base\InvalidRouteException: Unable to resolve the request “pharmacy/index”. in C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\base\Module.php:561
Stack trace:
#0 C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction(‘pharmacy/index’, Array)
#1 C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\base\Application.php(384): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 C:\xampp\htdocs\Medi\backend\web\index.php(17): yii\base\Application->run()
#3 {main}

Next yii\web\NotFoundHttpException: Page not found. in C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\web\Application.php:115
Stack trace:
#0 C:\xampp\htdocs\Medi\vendor\yiisoft\yii2\base\Application.php(384): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 C:\xampp\htdocs\Medi\backend\web\index.php(17): yii\base\Application->run()
#2 {main}

@evstevemd now when i enable pretty URLs and load the index.php with this http://localhost/medi/backend/web/index.php/pharmacy… it still flags Not Found (#404) and the Yii debug window/toolbar cannot be seen but it is enabled.when i deactivate the Pretty URL then i can see the error log on the Yii debug toolbar…is there something i am doing wrong?