cakephp interview questions
Top cakephp frequently asked interview questions
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 could help me, and whether it's worthwhile spending the time to learn a framework?
Source: (StackOverflow)
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 completely custom errors?
Source: (StackOverflow)
I am a CakePhp programmer. I have decided to try out the Yii framework. I would like to find out in what ways is CakePhp is similar to and different from Yii. Also, is Yii measurably faster than CakePhp as they claim?
Source: (StackOverflow)
I'm wondering, how do you guys unit-test in CakePHP?
How do you incorporate tests in projects?
What parts of a project do you test? How do you decide which parts gets to be unit-tested?
Do you guys still get to finish the job before the deadline?
Source: (StackOverflow)
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 live site. This query is failing but is being run.
something like this would be great:
$this->log($this->ModelName->lastQuery);
Thanks in advance.
Source: (StackOverflow)
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 object-oriented?
Source: (StackOverflow)
I and lately I'm seeing h() and e() functions in php...
I have googled them, but they are so short that results doesn't give any idea of what they are. I got results like exponential, or math related functions.
for example:
<td><?php echo h($room['Room']['message']) ?></td>
Does any one has an idea? or maybe they are not called functions? (I think I read about that very long ago, but I can remember its real name)
ADDED:
Thanks, for the replies.
I am using cakephp
and also found an e() example:
<?php e($time->niceShort($question['Question'] ['created'])) ?>
If they were escaping somehow strings I think it would make sense, since I always see them right next the "echo"
I still don't know what they are ;(
Source: (StackOverflow)
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("Vendor", "facebook");
statement right before the AppController
class gets defined. The referenced file is located under /app/vendors/facebook/facebook.php
(and includes itself the base_facebook.php
file).
I tried many different ways to include the file now in CakePHP 2.0 according to the File naming and class loading described here: File naming and class loading changes in CakePHP 2.0
I renamed the path to app/Vendor/Facebook/Facebook.php
, or app/Vendor/Facebook/facebook.php
, and tried following methods:
App::uses("Facebook", "Vendor/Facebook");
App::uses("Facebook", "Facebook");
App::uses("Facebook", "Vendor/Facebook/Facebook.php");
App::uses("Facebook", "Vendor");
Has anyone find a way to reference a vendor file yet? Because of the lazy loading the methods above do not fire an error/warning, so it's kind of annoying to debug this...
Source: (StackOverflow)
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 produce HTML something like this:
<div class="input text">
<label for="ModelAbc">Abc</label>
<input name="data[Model][Abc]" class="" maxlength="250" type="text" id="ModelAbc">
</div>
Now, sadly, Bootstrap wants something like the following:
<div class="control-group">
<label for="ModelAbc" class="control-label">Abc</label>
<div class="controls">
<input name="data[Model][Abc]" class="" maxlength="250" type="text" id="ModelAbc">
</div>
</div>
How do I make CakePHP produce this output?
Source: (StackOverflow)
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
Basically I have:
messages
table with a Message
model
users
table with User
model
and want to retrieve information from both tables in one query. The users.id
field is the same as the messages.from
field, so that's what the join is on.
I am doing it in my MessagesController
so it would need to be something like:
$this->Message->find();
Thanks
Source: (StackOverflow)
I've used CakePHP on several projects in the past, and have more recently started using Ruby on Rails, but there's a new project I'm about to start that will require PHP. While refreshing myself on CakePHP I learned that there is a new framework called Lithium that is essentially what CakePHP 3 was going to be. It's being developed by a group of former core CakePHP devs.
I haven't found a whole lot of information about it since it's still under development status, but I was wondering if anyone knows (or has a link to) some information on what benefits it provides over CakePHP. Hopefully something a bit beyond the quick overview shown on the official site. I'm trying to decide whether to use CakePHP for my upcoming PHP project or to wait a bit for Lithium to release a non-development version and try that out.
Source: (StackOverflow)
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 includes records that have '<' symbols in them. So naturally, the browser throws an error at that particular spot. How can this be fixed?
Source: (StackOverflow)
I get the following error when trying to logout of my CakePHP app:
Notice (8): Undefined property: UsersController::$Session [APP/controllers/users_controller.php, line 75]
Fatal error: Call to a member function setFlash() on a non-object in /Users/cameron/Sites/cakeapp/app/controllers/users_controller.php on line 75
This is the code for lines 74, 75 and 76:
function logout() {
$this->Session->setFlash('Good-Bye');
$this->redirect($this->Auth->logout());
}
Source: (StackOverflow)