Yii2 "Page not found" when using CRUD generator - crud

I have succesfully used Yii2 Model & CRUD Generators to obtain some skeleton code files for my web app. Particularly, the CRUD Generator claims to have succesfully created its view files into:
<yii_root>/basic/views/<my_view_name>/*.php
which I got by leaving "View Path" field blank.
However, browsing to:
https://<my_site_FQDN>/basic/web/index.php?r=<my_view_name>/index
spits a "Not Found (#404)" error and I'm unable to find any useful info in the Yii2 debug logs.
Any idea on this matter shall be welcome.
Antonio

<my_view_name> this is a terrible way of looking at this. Read about MVC.
You are creating controllers, routes are to controllers not to views. Stop looking if the views are there... look if the controller is there. You never interact with a view, you always do with a controller. So, is your controller there? are you sure you have created it?
Also what is the controller name? if you have something like ProductCategory then the correct route is
https://<my_site_FQDN>/basic/web/index.php?r=product-category/index
and not
https://<my_site_FQDN>/basic/web/index.php?r=ProductCategory/index
Edit
Ok, I see your problem, stop putting folders under other folders and so on. You created your CRUD wrong. Your controller has to be directly under controllers not under controllers/bibliografia, the same goes for the model. Delete the files and start again with CRUD as probably your namespaces are also wrong.

In my case, Yii2 consistenly writes the following with gii CRUD auto-generator.
namespace app\Controllers;
Notice uppercase 'C' for Controllers. This causes 404 error.
It should be :
namespace app\controllers
This fixed my 404 error.

I found with Yii2 (advanced template) that the generated controllers had:
namespace app\controllers;
I had to change this to:
namespace frontend\controllers;

I fixed it by capitalizing the first letter of the controller name.
Controller name should start with capital letters.
If lower case is used, Controller generator won't throw any error, but you will get not found(404) error in the browser.
this threw an error:
app\controllers\testController
this worked:
app\controllers\TestController

Its very Simple, change the namespace and please be careful while creating CRUD..
change namespace app\controllers; to namespace backend\controllers;

Related

Piranha CMS: Problem with custom block in manager interface

I am trying to add a custom block. I followed the steps in following two links:
http://piranhacms.org/docs/extensions/blocks
and
http://piranhacms.org/docs/manager-extensions/resources
In the CMS manager, I added the custom block to a page, but the block content is empty. Looks like the Vue.js didn't get associated to the custom block. I have set the block component attribute to the Vue.js.
I added the Vue.js by calling below method in the startup. Did I miss something to create a custom block?
App.Modules.Get<Piranha.Manager.Module>().Scripts.Add("~/assets/js/myscripts.js");
Move your "mycustomblock.js" file to the folder "wwwroot/js/" instead of the default "assets/js/". That way the file will be visible to Vue.js
Something is not working with the assets folder, probably it cannot be reached by Vue.js
after the Project is compiled. I had the same problem and this solution worked for me.
void Configure in Startup.cs will then look something like this (I simplified the syntax a bit compared to the documentation):
App.Modules.Manager().Scripts.Add("~/js/mycustomblock.js");
Adding a custom block and many other tasks have been difficult for me. Trial and error, and no knowledgebase to fall back on. The documentation is a fantastic start, and "Step by step" guides would be a good idea for the future (but I guess time is very limited).

cakephp 2 non existing controller and files could not be found

I make debug on a website running on cakephp 2 (yes it's old i know)
I have strange errors i cannot resolve.
in log i have:
-Error: [MissingControllerException] Controller class Wp-login.phpController could not be found
-Error: [MissingControllerException] Controller ColonisersController could not be found.
-Error: [MissingActionException] Action ImgController::ui-bg_diagonals-thick_90_eeeeee_40x40.png() could not be found.
-Error: [MissingActionException] Action ImgController::moustique-tigre-default.png() could not be found.
...
I search over all the source code for Colonisers but it is not write even once (also i think ColonisersController is a renammed controller because it is misspelled).
I search over the web for the Wp-login.php and it is a wordpress page, so no link to cakephp at all, also not write anywhere in the source code.
Same story for the missings pngs files. not in the source code.
I try to clear the cache folder on server but problems remains.
I have ghost source code? file are somewhere in another cache ?
any idea are welcomed.
By default all request that do not map to an actual file are being passed over to CakePHP, where the app will try to match the request to a route, and if one is found, finally try to match it to a controller and an action.
You seem to have some rather unspecific routes defined that eat pretty much anything as a possible controller name, hence things are being passed further for searching for a matching a controller and an action, which is where the request flow will end, as no matching controller or action can be found - consequently a MissingControllerException or MissingActionException is being triggered, an error is being logged (by default all exceptions are being logged), and in production mode (debug = 0) the app will respond with a 404 error.
So, no ghosts, no cached files, that's just how things work.

SilverStripe 3: Can a module extend mysite/code/Page.php?

Good afternoon,
I don't know if what I want to do is possible, so here goes.
I have a module that extends Page_Controller, but I want certain functions to be accessible via the site root.
Eg: getMyDataObjectList();
Currently, they only work if I go through the normal MVC routing structure.
I've found that when I place the function 'getMyDataObjectList' within '/mysite/code/Page.php' it works.The problem is, I don't want to place the code in there. I want it bundled with my Custom Module, but to work the same as though it was in 'mysite/code/Page.php'
[Example Scenario]
site root: http://[somesite].com
By default, the 'Page.ss' template loads.
I would like the theme developer to be able to call my module functions (API) within any template/Layout page, and have the result returned from the site root
Currently, this only works if I move the "API" functions to '/mysite/code/Page.php'
If the code is in my module, then data is only returned when you go to:
http://[somesite].com/[module_controller]
Can this be achieved? If so, how?
Thanks for your assistance.
[Update - Code Solution]
///>MyExtension.php
class MyExtension extends Extension{
public function getMyDataObjectList(){
return 'object list goes here!';
}
}//class
///>[Module] => _config.php
Object::add_extension('Page_Controller', 'MyExtension');
And as always, I do a (/dev/build?flush=1) just in case.
Thanks to: 'simon_w'
Yes, this is relatively straightforward. Simply, create an Extension subclass with your methods in them and then add that to Page_Controller. An Extension subclass is almost exactly the same as a DataExtension, they're just for classes other than DataObjects.

Yii with Bootstrap error (CWebApplication.bootstrap not defined)

I have followed this setup, but not work for me http://www.cniska.net/yii-bootstrap/setup.html, all CSS files do not give style to the page,
So searching I found this thread How to install bootstrap extension in yii using some tricks. But not work's too.
Now I have this error
'Property "CWebApplication.bootstrap" is not defined.'
Anyone can help or have any idea?
Thanks in advance and for my English.
Property "CWebApplication.bootstrap" is not defined.
The error means the system is trying to access Yii::app()->bootstrap, which could be a property on the application. Since bootstrap is a component it should be accessible, if the configuration is done properly.
This error is most likely because you forgot the following in the main config file:
'components'=>array(
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
),
// This should point to the location you placed the files in for example extensions/bootstrap/components/bootstrap.php
The class location above will only work if the alias is set properly before setting the configuration.
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
Instead you could also change "bootstrap.components.Bootstrap" into "application.extensions.bootstrap.components.bootstrap".
I strongly advise you to use Yiistrap, it was made by the person who create yii boostrap and the person who created Yiibooster. Yiistrap has everything from both extensions and more new stuff. here is the page http://www.getyiistrap.com , also has a fully documented API which yii boostrap do not have and it will save a lot of google searches.

Rails and mongoid: What is going on with RC7 and embedded documents?

Until now I was using rc6 and I decided to upgrade, but it's totally
breaking my app ? Maybe I am doing something wrong, but I believe I
followed the documentation.
I have a model Content that embeds_many Localized_Content.
Once I have a content created and wanted to added a localized content
I would do the following:
#content = Content.find('xxx')
#new_content = #content.localized_contants.build()
#new_content.save
This is working perfectly fine under rc6 and updates correctly all the
timestamps in localized_contant (using include Mongoid::Timestamps)
But doing the same thing in rc7 break with the following error:
"Access to the collection for LocalizedContent is not allowed since it
is an embedded document, please access a collection from the root
document."
Ok, maybe I need to save directly from the parent content then ok.
Doing a
#content.save
works but will not trigger all the timestamping
and this breaks the logic of my apps... what should I do ?
#content.save is the way to go. You should refactor your code to call save() on the parent object instead of the embedded document.