Questions tagged [cakephp-2.0]

Questions about the 2.0.x branch of the CakePHP MVC framework. If your question applies to CakePHP in general, use the tag [cakephp].

Use this tag for questions specifically about version 2.0.x of the CakePHP MVC framework. If your question applies to CakePHP more generally, use the tag .

CakePHP is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. Using commonly known design patterns like MVC and ORM within the convention over configuration paradigm, CakePHP reduces development costs and helps developers write less code.

4110 questions
35
votes
3 answers

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("Vendor", "facebook"); statement right before the…
Johannes N.
  • 2,278
  • 2
  • 25
  • 43
35
votes
8 answers

In View(CakePHP), the proper way to get current controller?

In View, I can get action by using $this->action But, I cannot get controller name by $this->controller What is the proper way to get current controller in View?
Hao
  • 5,661
  • 9
  • 34
  • 74
31
votes
7 answers

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 completely custom errors?
BadHorsie
  • 12,971
  • 26
  • 105
  • 175
23
votes
3 answers

Best way to load models in CakePHP 2.0

I'm not sure of the best way to load models in CakePHP 2.0 now. Question 1 I have a model where more than one database field is related to another model. customers table has the fields country_origin, country_residence and country_study and all of…
BadHorsie
  • 12,971
  • 26
  • 105
  • 175
23
votes
11 answers

CakePHP 2.0 with Twitter Bootstrap

Is there a way to configure CakePHP for it to work well with Twitter Bootstrap? I realize this question has already been asked here, but the answer wasn't really complete. There are also quite a few tutorials out there, but they are all either…
skimberk1
  • 1,984
  • 3
  • 19
  • 26
23
votes
8 answers

Efficient way to Pass variables from PHP to JavaScript

From time to time I have to pass some variables from PHP to JS script. For now I did it like this: var js-variable = ""; But this is very ugly and I can't hide my JS script in .js file because it has to be parsed by PHP.…
user606521
  • 11,796
  • 18
  • 90
  • 180
21
votes
8 answers

SplFileInfo::openFile(/app/tmp/cache/persistent/cake_core_cake_console_):failed to open stream:Permission denied in /lib/.../FileEngine.php line 293

I am working on a CakePHP 2 project. It originally started out in 2.0.x and then recently migrated to 2.1.0. Throughout the whole development process, I have been receiving the error message below. It pops up at the top of the page unpredictably. …
penguin egg
  • 1,094
  • 2
  • 10
  • 18
19
votes
1 answer

Find where id is not in array of ids

To find id whose value is equal to the id of an array of ids: $this->YourModel->find('all', array( 'conditions' => array( "YourModel.id" => array(1, 2, 3, 4) ) )); How I can do the opposite, find elements where the ids are different…
Martin
  • 1,115
  • 1
  • 12
  • 40
19
votes
3 answers

CakePHP - How to check in beforeSave if it's an INSERT or UPDATE

In my model's beforeSave method, how can I check if the save operation is going to be an INSERT or an UPDATE? I want to add to the model data, but only if it's inserting a new row.
BadHorsie
  • 12,971
  • 26
  • 105
  • 175
19
votes
3 answers

CakePHP 2.1.x - Run a query without any models in AppController

I am trying to run a query in AppController on a table that has no Model associated with it. I don't want to use a Model cause this query would fire on every request and I guess using a Model would make it a bit slower. I found out in one forum that…
Atul Dravid
  • 1,005
  • 3
  • 14
  • 29
17
votes
4 answers

Accessing Session in Model

Is there a way of accessing the current session in the AppModel class? I want to save the ID of the currently logged in user to almost every INSERT/UPDATE action.
powtac
  • 37,821
  • 25
  • 107
  • 164
16
votes
4 answers

CakeEmail - How do i use it?

In my controller i'm using a email function with the following code: public function email($mail = null){ $email = new CakeEmail('default'); $email->config('default'); $email->from(array('test@test.com' => 'testing')); …
user1192304
  • 217
  • 3
  • 8
16
votes
3 answers

Where to register event listeners

I'm trying to use the Event System in CakePHP v2.1+ It appears to be quite powerful, but the documentation is somewhat vague. Triggering the event seems pretty straight-forward, but I'm not sure how to register the corresponding listener(s) to…
emersonthis
  • 30,934
  • 52
  • 191
  • 328
16
votes
3 answers

Which is the best way to generate excel output in PHP?

Is there any other PHP components like PHPExcel?
Rodex
  • 197
  • 1
  • 2
  • 11
14
votes
1 answer

CakePHP 2.X - loading custom class in app/Lib dir

I have a class Called MyClass. It lives in app/Lib/MyDir/MyClass. I'd like to use App:uses() to load it, but can't get it to work. In CakePHP 1.3 I would load it via: App::import('Lib', 'MyDir/MyClass'); //this still works in CakePHP 2.1 In…
rynop
  • 41,200
  • 23
  • 87
  • 99
1
2 3
99 100