For the following application directory structure under / in Kohana 3:
application
classes
controller
controller1.php
modules
admin
classes
controller
controller2.php
And the urls be: /controller1 and /admin/controller2?
I seem to be missing something though because I keep getting a 404 error with the /admin/controller. What am I doing incorrectly?
The exact error is:
HTTP_Exception_404 [ 404 ]: The requested URL admin/borrowers was not found on this server.
And I don't have any custom routes setup. This is a very vanilla K3 install at this point.
The directory structure seems to be a little of.
Using a module doesn't automatically means you have a subdirectory. The default route defines the following url structure:
/[controller]/[action]
So for the directory structure that you have given, you get the following:
/controller2/
The action can be left out, but it will default to index.
If you want a special admin subdirectory, you would first have to create that subdirectory in you modules classes directory like this:
/admin/classes/admin/controller2.php
Then you would have to add another route that handles the subdirectory. You can find more information about that in the userguide
Related
I am using CodeIgniter for both frontend and backend. My backend isn't really that complex so it didn't warrant a different installation of CI. What I have now is a sub directory in controllers cms where I have all my backend controllers including a backend Index which extends MY_Backend core. Now I'm working on getting my front end up and running and have come across a problem if I have an Index file in the main controllers directory that extends MY_Frontend core. And try to access it via localhost or localhost/index I get a 404 page. If I change the name and subsequently the class name to Homepage I can access it via localhost/homepage.
Is this possibly due to having an Index file in the cms sub-directory? Otherwise, what is the issue? Here is my directory structure:
As at the base of it all controllers extend CI_Controller, there are 3 naming restrictions in place for controllers:
CI_Controller
Index
Default
Using any of these would cause a problem in some shape or form. I'd suspect this would be why your controller works fine named as Homepage, but not as Index.
Source: https://www.codeigniter.com/user_guide/general/reserved_names.html
I have worked on yii framework before and I had possibility to create module folder and inside this put eg: news module which was included controllers, views and module
I'm new in laravel and trying to create same thing MODULE
i tried the following inside routing
Route::get('/news','/modules/news/controllers/NewsController#index');
file exist but i'm getting
ReflectionException
Class /modules/news/controllers/NewsController does not exist
why ? what i'm doing wrong ?
The Route::get() function is looking for a (auto)loaded Class, not for a file on the disk to load, which is why you're getting these errors.
It's more Laravely (Laravelish?) to include:
Controllers in the /app/controllers/ directory
Views in /app/views/ directory
Models in the /app/models/ directory
And if you are starting out with Laravel, this might be the best way to get started. The autoloader knows where to look for your classes then, and everything gets handled automatically for you.
With the NewsController situated in /app/controllers/ you can do this:
// no need to start the route location with a slash:
Route::get('news', array('uses' => 'NewsController#index'));
You can "package" up functionality using Laravel's Packages, but it would be better to check out the excellent docs and then come back with specific questions..
Put your Laravel controllers in app/controllers, since that directory gets autoloaded, and it is where Laravel expects controllers to be.
Then you can use routes like this (example straight from the docs at http://laravel.com/docs/controllers#basic-controllers)
Route::get('user/{id}', 'UserController#showProfile');
I have he following url for my codeigniter application and I'm trying to find out how I can view this specific controller with the url. The my-project is what is used for my cms and the "admin" url segment is a variable representing a section of the cms area, "users" is the module from which I need to get the admin.php file for. I am using the wiredesignz 3rd page HMVC plugin into this application.
testsitehere.com/my-project/admin/users
-application
-modules
-users
-controllers
admin.php
I have tried the following route but still received the 404 error page.
$route['my-project/:any/:any'] = '$1/$2/admin';
What am I doing wrong for it to not work?
Try to use brackets:
$route['my-project/(:any)/(:any)'] = '$1/$2/admin';
I've noticed some people mentioning a similar request for controllers and sometimes models, but I've been unable to find anything on arranging plugins in subfolders.
I want...
/app
/Plugin
/Modules
/Form
/Controller
/Gallery
/Controller
/SomeStandardPlugin
/Controller
..so that I can keep all the CMS functionality specific plugins separate.
I've tried:
CakePlugin::load('Form');
CakePlugin::load('Modules/Form');
CakePlugin::load('../Plugin/Modules/Form');
No matter which of the above I try, when I attempt to make use of the controller in one of the plugins, it says:
Error: FormsController could not be found.
Error: Create the class FormsController below in file: app\Controller\FormsController.php
(Which would be fine if I didn't want it in a plugin!)
The CookBook didn't mention anything about it either - is it just not supported or am I missing something?
FYI: I'm using CakePHP v2.2.3
The argument for CakePlugin::load is not a path
The first argument for this function, is the name of a plugin. This is the correct way to load a plugin:
CakePlugin::load('Name');
But it will only work if the plugin exists in a location configured using App::build
As such, to organize plugins into subfolders, it's necessary to declare all paths that contain a plugin:
// append app/Plugin/Modules to the path to look for plugins
App::build(array(
'Plugin' => array(
APP . 'Plugin/Modules'
)
));
I am using Tank Auth library in Codeigniter with HMVC and the entire tank auth mvc files are in its own module called 'auth'. tank auth loads a view (domain.com/application/modules/auth/views/auth/login_form.php) found inside a folder (auth) using:
$this->load->view('auth/login_form', $data);
As far as I know the above code will load login_form.php inside the auth folder properly without HMVC. However with HMVC, I need the following code to get the view to load:
$this->load->view('auth/auth/login_form', $data);
Is there a setting that we should change so we dont have to refer to the view file by (module name)/(views folder name)/(view filename) ? Or is this perfectly normal and most people does it this way?
It seems troublesome that I have to add the module folder name 'auth' to every view() function call, and change all of them should I change the name of the module folder.
Assuming you're using Modular Extensions - HMVC:
If you have auth set up as a module already, you can just call:
$this->load->view('login_form', $data);
The file /views/login_form.php will be loaded from within the current module. This applies to models, language files, libraries etc. Think of the module as its own application, this is what you would normally do.
Additionally, to load a file from another module or a controller outside the module's directory, you can use $this->load->view('auth/login_form');
If the file is not found, it will check the other module paths including the default directory. This may or may not be the way other HMVC packages work, I'm not sure - but it's the way MX works.