Cakephp 2.1 naming convensions issue in version change - php

I have just installed CakePHP 2.1. And just see that the naming convention of its is just change lot from the older version which making me crazy.
Like it was app/controllers while now it is app/Controller same way
app/models - app/Model
app/views - app/View
I know there must be some advantage on doing this. But my problem is when I use the cake bake it is creating directory in the same old fashion i.e. controllers/models/views. Which is no more accessible from the URL & obviously will throw an error.
Is anyone there who has face the same issue ? Is there any solution that cake bake also use the same conventions ?
Any help will be appreciate. Thanks.

you can always use explicit paths:
/path/to/app_dir>..\lib\Cake\Console\cake bake
from your APP dir of the current cake project.
this is foolprove and always works with the right cake version.
I do it this way and use a shortcut on my keyboard to print this (up to "cake") on a single key stroke.

The reason for the change is to be able to better autoload files based on their kind (using App::uses('User', 'Model'); and later , when namespaces are introduced (3.0?) they can be loaded a lot more easy because you will call a class then like for example: "new \Cake\Model\User();"
About your bake problem: Make sure your environment is pointing to the correct "cake" shell file. I'm pretty sure yours is still pointing to the old 1.3 "cake" shell.

Related

How to configure Eclipse Project for Joomla Component Development

I like to develop a fresh Joomla Component for Joomla 3.x in Eclipse and created therefore a simple PHP project.
The problem I have is now how to setup the correct "include path", so that the basic Joomla PHP classes get found like "JFactory" , "JAccess", "JObject" ...
If I just include a Joomla installation in my include path, this will not work. I assume the paths to the classes are more sophisticated than that.
Any Idea or suggestion how the "include path" for my project should look like?
regards
Mark
It depends a little on what you mean by "found".
If you mean "as I start typing a basic class name every matching basic class gets offered as an option", yes, there is a way to do that.
See the conversation, and solution, on this gitHub page.
I have the stub file referred to and it works in the way I've said above, tho' I'm using NetBeans not Eclipse (but the reference to phpStorm makes me think it should/could work for you too), although I haven't been able to run the build script. I just haven't got the time to single step through it to find out where it stops.

Laravel File Paths

I am using laravel 4.2. I am following this basic tutorial on how to build Laravel Commands. I want to know where laravel is defining or registering the file paths to. For e.g.
use Illuminate\Console\Command;
is actually refering to the path below
vendor\laravel\framework\src\Illuminate\Console\Command.php
I am new to laravel, If you could point me to the right direction it would greatly help me.
there are two files you need to look at under app/config
one is start.php this register the basic path for the laravel source files the
base path . "/vendor/laravel/framework/src" .
the second one is app.php which provide an aliases array that correspond to the source classes and files.
for instance if you want to know where the class eloquent that your models are extending is at, you need to go to app.php see that Eloquent alias points toward 'Illuminate\Database\Eloquent\Model' and concat the path from start.php so it will be at \web\yourproject\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php
config.php holds the rest of the mapping.
So I studied how it locates the file it was using. Then I found out it is using a namespace. The book called CODE BRIGHT by Dayle Rees greatly helped me in understanding how namespacing works. You can scroll down under the section called THE PRIMERS where Dayle describes how it functions. It is easy to understand! Give it a try.

My CodeIgniter 3.0.3 model files cannot be found unless lcfirst (example_model.php)

I'm building a simple web application using CodeIgniter 3.0.3, and have run into a lot of issues regarding capitalization consistency. The CI 3.x documentation clearly states that Model files should be ucfirst and referenced using lcfirst i.e. file application/models/Foobar_model.php, loaded using $this->load->model('foobar_model'), and called with $this->foobar_model. Source: Official CI 3.x User Guide.
When I follow those rules, I get the following error message Unable to locate the model you have specified: foobar_model. Referencing the model using Ucfirst i.e. $this->load->model('Foobar_model') and $this->Foobar_model generates the exact same error message. I am able to resolve the issue by making my filename lcfirst application/models/foobar_model.php while the class name inside the file remains Ucfirst. As long as I name my file lcfirst foobar_model.php, it does not seem to matter whether I use Ucfirst or lcfirst to reference it from inside my controllers.
Strangely, I have found that I need to use application/controllers/Ucfirst_controller.php for my controllers with case-sensitive routing i.e. $route['default_controller'] = 'Ucfirst_controller';. I receive a 404 error when trying to route $route['default_controller'] = 'lcfirst_controller'; to application/controllers/lcfirst_controller.php.
Everything I have found on stackoverflow and other forums for CodeIgniter model and controller issues seems to involve people using lcfirst instead of Ucfirst on CodeIgniter 3.x, or using Ucfirst instead of lcfirst on CodeIgniter 2.x.
Basically my question is where is this case inconsistency coming from and how can I fix it? I want to follow standards so that others can join my project at a later point.
Other Info: I don't think that this should matter, but just in case. I am developing on LAMP on an Ubuntu machine with ext4 file formatting which is obviously case sensitive. I plan to deploy my project with Google Compute Engine running debian-7-wheezy with a HHVM stack. I am currently developing with just one partner, who is developing on a MAMP stack with non case-sensitive file formatting so he does not experience any of these issues.
Thanks everyone :~)
My system/core/Loader.php file was not updated properly when I updated from CI 2.x to 3.0.3. Properly updating this file resolved my case inconsistency issues, I am now able to name my models and controllers Ucfirst.php and reference them as $this->lcfirst and everything works properly.

Kohana: server can't find core.php because of naming convention change

I have a project written in Kohana 3. The /system subdirectory is pulled in via a git submodule:
[submodule "system"]
path = system
url = git://github.com/kohana/core.git
After version 3.3 it seems all classes were changed to the first letter being upper-cased. ie core.php is now Core.php. This didn't seem to have any effect locally on my mac but now that I've uploaded my app to hosting provider Fort Rabbit I'm getting an error that it failed to open system/classes/kohana/core.php. I suspect this is because that is now system/classes/kohana/Core.php
Can anyone advise the best way to proceed? Do I need to change every instance of require SYSPATH.'classes/kohana/classname'.EXT; to the uppercase equivalent?
Basically yes. In 3.3 when you call a class, you have to be case sensitive. The same applies to the file names. Migration guide explains this quite well.
You can also check this post to automate the upgrade.

Strange (for me) behavior of YII framework

I use YII framework and I needed to echo out query that is generated with the method insert($attributes=null) in CActiveModel class which, as it's told in documentation, is in framework/db/ar/CActiveRecord.php.
Well, my task was not hard, so I opened this file and edited this method, but nothing happened. After a little head-ache I've found out that my application was importing this class from the folder where I downloaded YII first.
What could be the reason of this behavior? I've solved my problem by changing path but I wonder, is it good solution?
Thank you in advance.
It's on index.php where you tell your application where to find the classes of the framework, so that's the line you should edit.
// change the following paths if necessary
$yii=dirname(__FILE__).'/../yii/framework/yii.php';

Categories