In CakePHP 2.x we used Router::url() to generate URL in any file. It works almost same with two major differennces though. The first one is that we have to call Router class manually wherever we want to use this function. Continue reading
I got started with my new CakePHP 3.x project today. As usual I wanted to create a few scaffold using
cake bake command. As I already had a CakePHP 2.x setup in my machine. I still needed it and its
cake bake commands to run to create any thing while working on the cakephp 2.x project. So is there a way I could use both cake bake consoles for CakePHP 2.x and 3.x respectively, at the same time?
Answer is YES. All we need to do is make some tweaks in order to run them both. Here are what I did.
- I actually went back into the CakePHP 2.x installation and renamed the cake and cake.bat to cake2 and cake2.bat respectively. There are located in C:\wamp\www\mycakephp2app\lib\Cake\Console.
This step actually was to set path environmental variable manually for CakePHP 3 as I already had set it up for CakePHP 2.x on my windows machine. I actually need them both. So I would add them like this C:\wamp\www\mycakephp2app\bin;C:\wamp\www\mycakephp2app\lib\Cake\Console;(for cakephp 3 it is set automatically.
If you installed Cakephp 2 after CakePHP was installed you have to set the environmental variable path accordingly)
- As you might have noticed that I renamed cake and cake.bat shell scripts to cake2 and cake2.bat respectively I need to run cake2 bake in order to invoke CakePHP baker.
I was making a url route like this:
Router::connect('/ca/assets', array('plugin' => 'file_manager', 'controller' => 'file_manager', 'action' => 'assets', 'ca'));
It worked alright with normal urls as- /ca/assets. However when i used paginator in view as
it generates url as- /assets/ca/page:2
I tried different things and at the end, as a work around to this problem I figured out that the following trick works. So make some heck in the $this->Paginator->options() function as the following:
$this->Paginator->options(array( 'url'=>array('controller' => 'ca', 'controller'=>'action', 'plugin'=>false) ));
Got a working copy of https://blueimp.github.io/jQuery-File-Upload/ file upload plugin for CakePHP 2.5.5 built as a plugin. Forked and modified from the original repository https://github.com/hugodias/FileUpload into https://github.com/inimist/FileUpload to incorporate latest files and functionality. Continue reading
As you know one would generate the cakephp table schema as:
$ cake schema generate
Want to switch between different databases in a CakePHP action? Do you want to use different database for different clients or sites? Don’t worry the solution more simpler than you thought it to be.
I am in a Task model.
I build following options to load the Task and associated User model data. Continue reading
Here is a piece of code placed as a helper function. Useful to create a delete button/link while having SoftDeleteBehavior enabled for a Model. For example, placed in data management page (view page such as admin_index.ctp or index.ctp) of your application. Continue reading