I was moving my cakephp application to a new server and had this issue: Error: The requested address “/” was not found on this server.
The following keys might resolve your issue:
1. Check your DATABASE_CONFIG (/app/config/database.php)
2. Delete all the cache files from all of your tmp subfolders (/app/tmp)
3. Make sure your /app/tmp folder (and all of its sub folders) are writable
If you still have issues with the app, you might have to change the debug switch to 2 or 3 in the /app/config/core.php
Find the line which says "Configure::write" and replace with the following:
Configure::write('debug', 3);
This would spit all the errors on your webpage. You can debug from there.
Showing posts with label cakePHP. Show all posts
Showing posts with label cakePHP. Show all posts
CakePHP: Multiple Inserts - Insert multiple rows using single statement.
Using the method saveAll(), we can achieve the desired goal. http://book.cakephp.org/view/75/Saving-Your-Data
Example:
If you want to save multiple records/rows into the same table.
This would result in inserting 3 rows in the "mymodelname" table.
Example:
If you want to save multiple records/rows into the same table.
$multipleRowData = Array(
Array('name' => 'Bob', 'phone' => "123-123-7777"),
Array('name' => 'Ann', 'phone' => "987-123-5555"),
Array('name' => 'Tom', 'phone' => "788-123-4569")
);
$this->Mymodelname->saveAll($multipleRowData);
This would result in inserting 3 rows in the "mymodelname" table.
CakePHP: Adding/deleting columns in the database after the application is Baked
If you had already baked the application and now if you made changes to the database by adding or deleting columns, then do the following:
1. Open "core.php" located at : app/config/core.php
2. Find the line which looks like: Configure::write('debug', 0);
3. Change it to Configure::write('debug', 2);
4. Refresh your application webpage.
5. Reset the line in core.php to Configure::write('debug', 0);
What basically this will do is refreshing the "model" cache.
Changing the debug level will ensure that all your databases changes are reloaded.
Following are the notes related to which debug level, you want to set.
/**
* CakePHP Debug Level:
*
* Production Mode:
* 0: No error messages, errors, or warnings shown. Flash messages redirect.
*
* Development Mode:
* 1: Errors and warnings shown, model caches refreshed, flash messages halted.
* 2: As in 1, but also with full debug messages and SQL output.
* 3: As in 2, but also with full controller dump. (NOTE: Not in CakePHP 1.3)
*
* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/
1. Open "core.php" located at : app/config/core.php
2. Find the line which looks like: Configure::write('debug', 0);
3. Change it to Configure::write('debug', 2);
4. Refresh your application webpage.
5. Reset the line in core.php to Configure::write('debug', 0);
What basically this will do is refreshing the "model" cache.
Changing the debug level will ensure that all your databases changes are reloaded.
Following are the notes related to which debug level, you want to set.
/**
* CakePHP Debug Level:
*
* Production Mode:
* 0: No error messages, errors, or warnings shown. Flash messages redirect.
*
* Development Mode:
* 1: Errors and warnings shown, model caches refreshed, flash messages halted.
* 2: As in 1, but also with full debug messages and SQL output.
* 3: As in 2, but also with full controller dump. (NOTE: Not in CakePHP 1.3)
*
* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/
CakePHP: remove cakePHP Flash messages using JQuery
Typically you would have all the cakePHP flash messages inside the div - alert_messages.
By using JQuery, we can remove these after intended time period.
The following example removes the cakePHP flash message after 5 seconds time period.
By using JQuery, we can remove these after intended time period.
The following example removes the cakePHP flash message after 5 seconds time period.
$(document).ready(function() {
$('#alert_messages').animate({opacity: 1.0}, 5000).fadeOut();
});
jQuery, CakePHP: Submit a form using ajax; implementing "quick save"
In CakePHP, If you want to submit a FORM using an AJAX request, use jQuery Form Plugin.
You can find a detailed example at http://marcgrabanski.com/article/cakephp-ajax-quick-save-jquery
An alternative to this plugin is invoking a javascript function, when a submit button is clicked, and which would read all the input data inside the form and send it to the controller.
You can find a detailed example at http://marcgrabanski.com/article/cakephp-ajax-quick-save-jquery
An alternative to this plugin is invoking a javascript function, when a submit button is clicked, and which would read all the input data inside the form and send it to the controller.
cakePHP: Passing multiple parameters from view to controller in cakePHP
There is no direct specification for passing multiple parameters from view (.ctp file) to controller (.php file) in cakePHP. It is intuitive !
The format of the url with a single parameter look like : ../myApp/myController/myFunction/parameter1
To pass multiple parameters simply append at the end which might look like
../myApp/myController/myFunction/parameter1/parameter2/parameter3
Some generic ways are:
1.
array ('action' = '/myFunction/'. $id .'/'.$another_id);
2.
$Html-> link ('edit', array ('url'='/ myController/myFunction? Id ='. $Id. '& another_id ='. $another_id)).
3.
$Html-> link ('edit', array ('action' = 'myFunction', $id,$another_id)).
The function in myController would look like:
function myFunction ($id, $another_id){
// do something
}
The format of the url with a single parameter look like : ../myApp/myController/myFunction/parameter1
To pass multiple parameters simply append at the end which might look like
../myApp/myController/myFunction/parameter1/parameter2/parameter3
Some generic ways are:
1.
array ('action' = '/myFunction/'. $id .'/'.$another_id);
2.
$Html-> link ('edit', array ('url'='/ myController/myFunction? Id ='. $Id. '& another_id ='. $another_id)).
3.
$Html-> link ('edit', array ('action' = 'myFunction', $id,$another_id)).
The function in myController would look like:
function myFunction ($id, $another_id){
// do something
}
CakePHP : DbAcl::allow() - Invalid node [CORE\cake\libs\controller\components\acl.php, line 325]
DbAcl::allow() - Invalid node [CORE\cake\libs\controller\components\acl.php, line 325]
If your following the “Simple Acl Controlled Application” , then you might see the above error message.
A simple fix is, in the function 'initDB()' replace
$this->Acl->allow($group, 'controllers');
with
$this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 1), 'controllers');
So the total function would look like the following:
If your following the “Simple Acl Controlled Application” , then you might see the above error message.
A simple fix is, in the function 'initDB()' replace
$this->Acl->allow($group, 'controllers');
with
$this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 1), 'controllers');
So the total function would look like the following:
function initDB() {
$group =& $this->User->Group;
//Allow admins to everything
$this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 1), 'controllers');
//allow managers to posts and widgets
$this->Acl->deny(array( 'model' => 'Group', 'foreign_key' => 2), 'controllers');
$this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 2), 'controllers/Posts');
$this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 2), 'controllers/Widgets');
//allow users to only add and edit on posts and widgets
$this->Acl->deny(array( 'model' => 'Group', 'foreign_key' => 3), 'controllers');
$this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 3), 'controllers/Posts/add');
$this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 3), 'controllers/Posts/edit');
$this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 3), 'controllers/Widgets/add');
$this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 3), 'controllers/Widgets/edit');
}
Associating CakePHP files ( *.ctp or *.thtml ) with Eclipse
To set up your version of Eclipse to read either file type( *.ctp or *.thtml), follow these steps
- Go to Window > Preferences > General > Content types
- In the content types window navigate the tree to text > PHP content type
- Click add
- Enter *.ctp or *.thtml depending on what version of CakePHP you use. It might be best to add both - just in case.
- Now navigate to Editors > File Associations
- Enter *.ctp or *.thtml depending on what version of CakePHP you use.
- Under "Associated Editors:", select the PHP Editor and click Default.
Using CakePHP BAKE : A Fast and simple start for Web Application
Using CakePHP BAKE feature is really very easy to setup the building stone for the web application with all basic functionalities.
Here are the steps to start baking easily.
Assuming you created your Database....
1. Download the latest stable release from http://cakephp.org/
2. Rename it to your desired app name and place it in your Web Server root directory.
3. Open terminal and goto ur Web Server root directory/urAppName/cake/console
4. Execute the command : ./cake bake
5. Follow the wizard to complete the baking !
Here are the steps to start baking easily.
Assuming you created your Database....
1. Download the latest stable release from http://cakephp.org/
2. Rename it to your desired app name and place it in your Web Server root directory.
3. Open terminal and goto ur Web Server root directory/urAppName/cake/console
4. Execute the command : ./cake bake
5. Follow the wizard to complete the baking !
Subscribe to:
Posts (Atom)
Python contextlib for Timing Python code
If you've ever found yourself needing to measure the execution time of specific portions of your Python code, the `contextlib` module o...
-
If you get the following error while installing FFMPEG or other packages on CentOS 7. Requires: libva.so.1(VA_API_0.33.0)(64bit) Follow...
-
Common error: fallocate: fallocate failed: Text file busy in ubuntu OS Check the allocation: free -m or sudo swapon --show Make sure ...
-
How to fix Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' Apparently, Ma...