I have a controller named CategoryAdminController.php which can be accessed by {siteurl}/categoryadmin/index in my localhost which is on a Windows machine. But when I try to launch it in my remote server which is on a Linux platform, it is unable to load the page. But when I rename my controller as CategoryadminController.php (and the class name accordingly), it is working fine.
Is there any way to load the page while keeping the original name in the controller (ie: CategoryAdminController.php)
According to Yii guide, seems it is not possible.
http://www.yiiframework.com/doc/guide/1.1/en/basics.convention
Any ideas?
Thank you
To keep Controller names and Action names CamelCased and working on Linux, you need to add dash between each word in the URL:
"{siteurl}/category-admin/index" -> CategoryAdminController->indexAction()
"{siteurl}/category-admin/my-way" -> CategoryAdminControllern->myWayAction()
This will work both on Linux and Windows.
Windows reads files and folders case-insensitive. And often hides some of the mistakes.
The common issue comes when you develop on Windows ... and create a link categoryadmin the OS will find be happy to give you a file like
CaTegoRYadmiNcontroller.php ignoring the capitalization.
But when you deploy the same code and files on Linux you will get File Not Found exceptions.
So, better stick to the convention.
It is case-sensitive for a file's name when on a Linux OS, but not on Windows. Did you try to access it: {siteurl}/categoryAdmin/index ?
You can rewrite the URLs by using the urlManager. In your case you can use the following code:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => FALSE,
'rules' => array(
'categoryadmin/<action:\w+>' => 'categoryAdmin/<action>'
),
),
Related
The following URL part works as expected on my Windows WAMP machine (running using AMPPS), but fails on the Linux production host:
index.php?r=customchocolates/index
I get the following error:
Unable to resolve the request "customchocolates/index"
On Windows, I followed the naming convention of CustomChocolates in all the relevant files. However, after searching on-line, I changed the following files to:
controller: customChocolatesController.php
model: customChocolates.php
views dir: customChocolates
I've also updated all the class names to the new name, but I'm still getting the error.
Windows = file name case insensitive
Linux = file name case sensitive
Change your route to customChocolates/index
Try to rename customChocolatesController.php to CustomChocolatesController.php, and be sure, that controller class name also CustomChocolatesController.
And rename you route as nkamm says.
Moved my site to my Linux laptop to reproduce the problem. Got the same problem as on production.
I solved it (I don't know why - perhaps someone more knowledgeable and experienced can explain) by doing the following:
renamed controller file and class names to CustomchocolatesController
Removed caseSensitive from URLManager block in config
Renamed views folder to customchocolates
Thanks to #nkamm and #Mihail for their time last night.
I have been debugging this for quite some time and am unable to find any solution - so this is my last hope.
I am trying to install/configure an extension for Yii called minScript by following this installation guide.
I place the extracted extension in my extensions folder, and change the config/main.php to the following:
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Demo app',
'controllerMap'=>array(
'min'=>array(
'class'=>'ext.minScript.controllers.ExtMinScriptController',
),
),
...
// application components
'components'=>array(
'clientScript'=>array(
'class'=>'ext.minScript.components.ExtMinScript',
'minScriptDebug'=>true,
),
...
Although when I try to run it, I get an error message:
CException
Alias "ext.minScript.components.ExtMinScript" is invalid. Make sure it points to an existing PHP file and the file is readable.
The file exists in the defined folder and is readable, yet the error message always appears.
Anyone have any idea what I am doing wrong?
If your installation is on Linux, be careful with spelling in file and directory names. I wasted a lot of time trying to solve the same problem with views and other components or extensions,
If not, try removing:
'minScriptDebug'=>true,
From your 'components' block.
Also assets and protected/runtime should be writtable (recursively).
Your file structure should look like:
protected/extensions/minScript/
components/
ExtMinScript.php
controllers/
ExtMinScriptController.php
vendors/...
minify/...
And finally maybe you have a trouble with urls, routing rules or with your .htaccess / web server setup. In first case, in config/main.php I use all the urls with format domain.com/site/parm1/parm2 and adding this before routing rules solved the trouble:
'urlManager'=>array(
'urlFormat'=>'path',
EDIT: I forgot this:
'controllerMap' section should be after 'components' in config/main.php,
Good luck!
Try insert before return (you need to declare alias ext - set it on extension directory):
Yii::setPathOfAlias('ext',
dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'extension';
I just created a module with a submodule like Backend\Entity1. I checked every path and namespace, they all seem to be ok.
I took out codeblocks one by one but stil I just get via Firebug a
"NetworkError: 500 Internal Server Error"
Any ideas what I can do to find the error?
I just don't know what might be wrong. Honestly, why does the framework explain itself what is happening? Its just fishing in the dark now...
BTW: The error.log doesn't show something either...
Edit:
I'm guessing that this error is raised because my app can't find the phtml files. Maybe I'm wrong but usually when I get this kind of silly error it has something to do with missing files...
My config code looks like this:
'view_manager' => array(
'template_path_stack' => array(
'entity' => __DIR__ . '/../view',
),
),
My namespace is MasterData\Entity and my add/edit/delete/index.phtml lie under view\masterdata\entity.
Any ideas how I can tell the TemplatePathStack how to look in this dir for my files?
If your want your sub module to be accessed create proper route in the parent module to make a way to access your sub module.
I IMHO if you need to create sub modules, create as module and place the modules under modules folder of your application, if you have components or third party modules place it under vendor folder.
This would be easier to manage at later stages an your url will also be much simpler
In my case, I created the new model in another way but I had the same error when I tried to see the result in the explorer. The problem (in my situation) was the access to files from the explorer, It resolves by changing files's permissions in linux's terminal.
I've started to learn kohana fews days ago and with my Zend Framework my learning experience seems to be fast until i run into couple of issues.
First of all i started the project in windows 7(dual booting with linux ubuntu 12.04). i know every link was fine before i started adding more pages to an admin app with kendo ui. i've added couple of routes to handle controllers in subfolders and to handle url with query string of the form ?bla=dkll&second=lkdjf (used by kendo grid to send unknown number of params based on users interaction with the grid).
First problem : under windows i would access any url except the root / eg localhost/admin/ (admin being my folder in htdocs) it gives me
ERROR: HTTP_Exception_404 [ 404 ]: The requested URL / was not found on this server :
83 try
84 {
85 if ( ! class_exists($prefix.$controller))
86 {
87 throw new HTTP_Exception_404('The requested URL :uri was not found on this server.',
88 array(':uri' => $request->uri()));
89 }
90
91 // Load the controller using reflection
92 $class = new ReflectionClass($prefix.$controller);
Second problem : Under ubuntu not only i have the same first problem but then i can't even hit other urls like localhost/admin/useraccess/login
Questions:
is the second problem related to the first one (obviously aside the '/' not found one)
i have enabled on ubuntu mod_rewrite and the kohana install page is all green.
is there any other settings i forgot to enable which was enabled in windows php (xampp) that's not on ubuntu?
my .htaccess/logs/boostrap are found here
thanks for reading this and helping out
I assume that root folder of your application is 'admin'. In bootstrap.php you should have:
Kohana::init(array(
'base_url' => '/admin',
'index_file' => FALSE,
));
Also in your bootstrap.php default route should be last route:
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'index',
'action' => 'index',
));
Other routes that you add should take place above default route.
I have same problem with you, my kohana running well on my windows machine. but when i migrate it to Ubuntu I have a problem with routing. This is my bad, i forgot to edit my apache conf. You can look into conf file in /etc/apache2/sites-enabled/000-default
Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
/Directory>
edit 'AllowOverride None' to 'AllowOverride All' and restart your apache webserver .
Works like magic !!
To add to digby's note: All class file names and directory names are lowercase.
There are a few little things I noticed but nothing that could explain the problem you are having:
Query strings should not be and are not used to route to an action. Use $this->request->query() in controllers to use GET values.
Slashes get trimed off the beginning and end of URI's, so the optional / in the commented out 'def' route is useless.
The second time defining the kendogrid route overwrites the old one. Not that it really matters since they are the same, so why not remove one?
What controller do you expect to be routed too? Currently it should be Controller_... Hmm... I spy with my little eye a typo! 'susbcribers' instead of 'subscribers'. So currently you will be routed to Controller_Susbcribers::index().
If you want the Controller_Useraccess::index() instead of Controller_Subscribers::index() (assuming you fix the typo) remove the first kendogrid route since both 'kendogrid' and 'default' match an empty URI.
PS. I am assuming you use 3.2
I made a custom helper extending the system string_helper.php.
I placed it in my /application/helpers directory, called it MY_string_helper.php as required, unit-tested its functions.
Now, when I try to call one of its functions from a model, it does not work.
The functions in the default string helper work, instead. It looks like my extension is not loaded for some reasons.
Thanks a lot, and happy holidays.
Edit: even funnier. I saved the file as categories_helper.php in the system/helpers directory, and when I try to load it within a model i got the following response: *Unable to load the requested file: helpers/categories_helper.php*
I had the same problem. I came from windows OS development of my codeigniter project, then shifted to Ubuntu, but somehow it still didn't load my helpers.
I found that changing the naming convention to lowercase solves the problem. Don't follow what's written in the doc where you are given a prefix to insert, especially if it's in uppercase. Make use of lowercase.
The Codeigniter User Guide for helpers describes that helpers are available to controllers and views only. It does not explicitly mention that helper functions work in models.
CodeIgniter does not load Helper Files
by default, so the first step in using
a Helper is to load it. Once loaded,
it becomes globally available in your
controller and views.
Linux is case sensitive, Windows no. So, if you are development in OS Windows, before upload your system in a Linux hosting foe example, you need have the names of the files in lowcase.
For example:
In Windows: application/helpers/MY_functions_helpers.php
In Linux: application/helpers/my_functions_helpers.php
mmm, i'm not sure it will work for helpers, but have you tried to load the helper in this way?
$CI = & get_instance();
$CI->load->helper('string');
I faced a similar kind of situation. My development environment was WINDOWS and it worked fine as described in the DOCs i.e. MY_string_helper.php
On the production environment of UNIX, it gave error:
Unable to load the requested file: helpers/my_form_helper.php
Changing the file name to lower case resolved this error BUT the helper was not actually loaded.
After a lot of time waste, by hit and trail it worked [ it is un-documented ]
In the autoload.php, just include the mention the extended helper before the default helper:
$autoload['helper'] = array('my_string', 'string');
Also, the prefix has to capital, it did not work with lower case prefix:
$config['subclass_prefix'] = 'MY_';
you just have to change your helper function name with your prefix like found in application/config/config.php
after helper renamed make sure it contains small letters only
then change autoload file with the function name that you renamed,
main problem because of OS like your Hosting server is linux and you develope with windows so this problem rise