Questions tagged [cakephp]
CakePHP is an open-source web, rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. It uses commonly known design patterns like MVC and ORM within the convention over configuration paradigm.
31,683
questions
114
votes
3
answers
219k
views
"[notice] child pid XXXX exit signal Segmentation fault (11)" in apache error.log [closed]
I am using Apache/PHP/MySQL stack.
Using as framework CakePHP.
Every now and then I get a blank white page. I can't debug it through Cake, so I peek in the apache error.log and here's what I get:
[...
110
votes
9
answers
132k
views
Best way to document Array options in PHPDoc?
I'm struggling to write readable and easy to understand documentation that describes the multi-tree structure for Array options that are passed to a function.
Here is an example array structure.
$...
101
votes
6
answers
144k
views
Set Response Status Code [duplicate]
I have an API call for which I need to be able to run some checks and potentially return various status codes. I don't need custom views or anything, I just need to return the proper code. If the user ...
87
votes
7
answers
124k
views
How do you make strings "XML safe"?
I am responding to an AJAX call by sending it an XML document through PHP echos. In order to form this XML document, I loop through the records of a database. The problem is that the database ...
80
votes
9
answers
269k
views
How to check not in array element
I am trying to check if an element is not in array than want to redirect page:
My code is as below:
$id = $access_data['Privilege']['id'];
if(!in_array($id,$user_access_arr))
{
$this->Session-...
79
votes
9
answers
158k
views
How can I see CakePHP's SQL dump in the controller?
Is there a way that one can cause CakePHP to dump its SQL log on demand? I'd like to execute code up until a point in my controller and see what SQL has been run.
76
votes
2
answers
13k
views
Fat models, skinny controllers and the MVC design pattern [closed]
I just read a blog post that explains MVC with a banking analogy. I have a few months of experience with web application development with an MVC framework (CakePHP), so I get the basics, but I began ...
69
votes
18
answers
110k
views
CakePHP 3.0 installation: intl extension missing from system
Using the CakePHP docs, I am trying to install 3.0-beta2 using composer but I got this error:
cakephp/cakephp 3.0.x-dev requires ext-intl * -> the requested PHP extension intl is missing from ...
69
votes
2
answers
195k
views
What is /var/www/html? [closed]
I am starting to pick up PHP / MySQL, but in all the documentation I'm reading, it mentions /var/www/html as being the folder you want to install a framework such as CakePHP, or for example /var/www/...
67
votes
15
answers
232k
views
PHP Fatal error: Class 'PDO' not found
PHP Fatal error: Class 'PDO' not found in /home/bd/public_html/app/webroot/Cake/Model/Datasource/Database/Mysql.php on line 177
PHP INFO:
PDO
PDO support => enabled
PDO drivers => sqlite, ...
63
votes
25
answers
151k
views
How to get complete current url for Cakephp
How do you echo out current URL in Cake's view?
63
votes
15
answers
164k
views
Input value doesn't display. How is that possible?
This must be something utterly stupid that I've done or am doing, but I have an input with a value attribute that simply isn't being displayed:
<div class="input text required">
<...
63
votes
7
answers
244k
views
Request exceeded the limit of 10 internal redirects due to probable configuration error
I'm getting the following error in my CakePHP application:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit ...
62
votes
4
answers
208k
views
Generate ER Diagram from existing MySQL database, created for CakePHP [closed]
For CakePHP application, I created MySQL database.
Which tool to be used to create ER Diagram of database? Fields and relations between tables are created in a way cakePHP likes.
thank you in ...
56
votes
8
answers
79k
views
Can I use one model inside of a different model in CakePHP?
Can I use another Model inside one model?
Eg.
<?php
class Form extends AppModel
{
var $name='Form';
var $helpers=array('Html','Ajax','Javascript','Form');
var $components = array( '...
56
votes
9
answers
34k
views
symfony vs cakephp [closed]
What is conceptually the difference between symfony and cakephp?
52
votes
9
answers
85k
views
CakePHP: Find where field is not null
I need to select all rows where User.site_url is not null. It's simple enough to do this in a regular MySQL query but how is this done in CakePHP?
The manual mentions the following:
array ("not&...
51
votes
14
answers
79k
views
How can I tell which CakePHP version is a project made with?
Is it possible to know the version of CakePHP used to generate a project with only the app code available?
My problem:
I downloaded a project made with CakePHP, and I really can't tell which Cake ...
51
votes
6
answers
149k
views
CentOS: Enabling GD Support in PHP Installation
How do I go about enabling GD Support in a CentOS Installation?
50
votes
22
answers
125k
views
What is the equivalent to getLastInsertId() in Cakephp?
If I do getLastInsertId() immediately after a save(), it works, but otherwise it does not. This is demonstrated in my controller:
function designpage() {
//to create a form Untitled
$this->...
50
votes
3
answers
23k
views
How to unit test your API?
I'm at the point where I need to write unit tests for a REST API written using CakePHP 1.3. The API supports GET, POST and PUT requests for querying and manipulating data.
Is there any established ...
49
votes
7
answers
60k
views
Is PHP Object-oriented?
Is PHP an object-oriented language? If not, then what about the framework CakePHP? Is it an object-oriented MVC implementation of PHP?
Also, can a PHP application wholly built using classes be called ...
48
votes
1
answer
20k
views
How to store repeating dates keeping in mind Daylight Savings Time
I'm storing events in my database. I have 'start' and 'end' date times, 'tickets_start' and 'tickets_end' (for when ticket sales actually start/end - as opposed to the start/end of the actual event).
...
48
votes
3
answers
22k
views
PHPUnit's returnValueMap not yielding expected results
I'm trying to use PHPUnit's returnValueMap() to stub out the results of a read. It isn't yielding the expected results, but an equivalent returnCallback() does. I've made my test case available if ...
47
votes
12
answers
59k
views
What is a .ctp file used for in CakePHP?
I'm starting to use CakePHP, and I'm in the process of reading the manual. About halfway down the page, there's this comment:
// Render the element in /views/elements/ajaxreturn.ctp
So a very ...
45
votes
11
answers
88k
views
CakePHP - get last query run
I want to get the last query CakePHP ran. I can't turn debug on in core.php and I can't run the code locally. I need a way to get the last sql query and log it to the error log without effecting the ...
44
votes
3
answers
115k
views
CakePHP find method with JOIN
Hi,
I need to do the following query using the CakePHP find method:
SELECT *
FROM `messages`
INNER JOIN users ON messages.from = users.id
WHERE messages.to = 4
ORDER BY messages.datetime DESC
...
43
votes
2
answers
24k
views
Display CTP Files as PHP Files in PHPStorm
I have a project running on CakePHP. All of my views are stored as ctp files. How do I render my ctp files so I have the same visual formatting that's present when I look at a file that is stored as ...
42
votes
3
answers
164k
views
how we add or remove readonly attribute from textbox on clicking radion button in cakephp using jquery?
Here is my cakephp generated HTML radio box and text box script:
<input type="radio" id="need_staff_on_site" name="data[CaterRequest][need_staff_on_site]" value="yes" class="staff_on_site"><...
41
votes
5
answers
108k
views
How do you update a cookie in PHP?
If I call setcookie() two times with the same cookie name, I get two cookies created.
How do you update an existing cookie?
40
votes
13
answers
49k
views
php e() and h() functions?
I and lately I'm seeing h() and e() functions in PHP. I have googled them, but they are so short that results don't give any idea of what they are. I got results like exponential or math related ...
40
votes
7
answers
71k
views
save() returning false, but with no error in CakePHP
My debug value is set to 2, and it's displaying all the queries, except the one I need.
I have an Items controller method that is calling this method in the User model (Item belongsTo User):
...
40
votes
3
answers
65k
views
Cakephp cake_core_ cache was unable to write 'cake_dev_en-us'
I have tried EVERYTHING but i keep getting the following cake error:
( ! ) Warning: _cake_core_ cache was unable to write 'cake_dev_en-us' to File cache in /var/www/bloglic-2013/cake/lib/Cake/Cache/...
39
votes
4
answers
62k
views
The processing instruction target matching "[xX][mM][lL]" is not allowed [duplicate]
I'm outputting XML in CakePHP. But I'm getting this error when I put my XML into a validator:
The processing instruction target matching "[xX][mM][lL]" is not allowed.
I am using correct XML layout ...
39
votes
2
answers
43k
views
Cakephp check if record exists
I am wondering, is there a function that allows me to check instantly if a record in the database exists?
Right now I am using the following piece of code to detect if a record exists, but I can ...
39
votes
8
answers
10k
views
Speeding up CakePHP
I've been a keen fan and user of CakePHP for about 2.5 years now, but the main bugbear that most fellow developers level at the framework is that it's slow, and the dispatch cycle takes too long to ...
38
votes
3
answers
28k
views
How to declare the type for local variables using PHPDoc notation?
I use Zend Studio to develop in PHP with CakePHP, and one of the problems with CakePHP is that the views all reference undeclared local variables.
So for example, in the controller you would
$this-&...
37
votes
7
answers
95k
views
base_url in CakePHP
In most web applications we need global var base_url. In cakephp to get base_url currently i put the following code on beforeRender method in app_controller.php
function beforeRender(){
$this->...
36
votes
19
answers
79k
views
CakePHP Database connection "Mysql" is missing, or could not be created
There have been several other posts about this, but none of the answers seemed to work for me.
When I navigate to the CakePHP page on my local machine, there is one error:
Cake is NOT able to ...
35
votes
12
answers
507k
views
404 Not Found The requested URL was not found on this server
I'm having small troubles and was wondering if someone can help me over the hump. I pulled a copy of a website down from Hostgator and I'm trying to set it up on my local machine using WAMP but, I ...
35
votes
3
answers
52k
views
Loading Vendor Files in CakePHP 2.0
I'm currently upgrading one of our projects to CakePHP 2.0. Unfortunately the "first line" of code makes problems, and I can't find a solution to that problem.
In CakePHP 1.3 I had an App::import("...
34
votes
12
answers
18k
views
To Use a PHP Framework or Not? [closed]
I've started writing a few applications in PHP, and I'm becoming more familiar with the language. Someone told me about CakePHP, and CodeIgniter. I wanted to get a better understanding of how these ...
34
votes
4
answers
178k
views
Undefined variable: $_SESSION
I'm getting E_NOTICE errors in a core CakePHP file when it tries to reference a never-set or unset session (cake/libs/cake_session.php line 372):
function read($name = null) {
if (is_null($name)) ...
33
votes
2
answers
37k
views
How can I run composer without user interaction?
I'm trying to run composer install on a cakephp installation, however it asks the user if they want to they want to set folder permissions:
Note, this is an example. In production the composer ...
33
votes
4
answers
21k
views
Asynchronous processing or message queues in PHP (CakePHP) [closed]
I am building a website in CakePHP that processes files uploaded though an XML-RPC API and though a web frontend. Files need to be scanned by ClamAV, thumbnails need to be generated, et cetera. All ...
32
votes
7
answers
106k
views
Rendering controller to a different view in CakePHP
Is there a way to render a controller to a different view then normal? I'm trying to pass some data from the controller to a non-default view. Meaning my controller is called:
class ...
32
votes
7
answers
62k
views
How do I update 1 field in CakePHP?
I want a function to alter one field, "is_featured" to 1(true) of Event model of given ID, to mark an event as "Featured".
class EventsController extends AppController{
function feature($id){}
}
31
votes
10
answers
33k
views
How do you specify an HTTP status code in Cakephp?
In my controller, I check a condition to see if the user is allowed to do something. If the check fails, I want to send a 403 back to the browser. How do I do that in Cakephp?
31
votes
7
answers
42k
views
CakePHP 2.0 - How to make custom error pages?
I read that the AppError class is now for backwards compatibility and that Exceptions should be used instead. How does one go about creating custom error pages for things like 404 errors, or ...
31
votes
9
answers
32k
views
Using CakePHP FormHelper with Bootstrap Forms
CakePHP's FormHelper is how you generate forms when making CakePHP applications. As one might assume, this includes generating input elements, like so:
$this->Form->input('abc');
Which will ...