cakephp-2.2

URL Rewrite create subdomain in cakephp

一曲冷凌霜 提交于 2019-12-05 02:37:14
I am using Cakephp framework 2.2.2. I want to create a personalized URL for the user. For example, if a user enters username=pragnesh , then they can access my site like: http://pragnesh.mylocalhost.com , same as in blinksale.com My URL: http://mylocalhost.com/test/users/front_home I want to access it at: http://test.mylocalhost.com/users/front_home My URL: http://mylocalhost.com/test/setting/pages can be accessed at: http://test.mylocalhost.com/setting/pages any URL: http://mylocalhost.com/test/xxxxx/xxxxx can be accessed at : http://test.mylocalhost.com/xxxxx/xxxxx OR URL: http://mylocalhost

CakePHP Error: Unable to configure the session, setting session.auto_start failed

旧城冷巷雨未停 提交于 2019-12-02 18:40:05
I'm getting this error: Error: [CakeSessionException] Unable to configure the session, setting session.auto_start failed. I'm using Cakephp 2.2.4. EDIT It seems this guy had the same issue: Cakephp Session error on live site and using this if(!isset($_SESSION)) session_start(); inside beforefilter method of AppController fix the error. So my question is: why this happened? Everything was working fine and then suddendly this error appeared. Additionally I've realized that the folder app/tmp/sessions is empty and I have configured the session to be handled by Cake (in Config/core.php ). In PHP

Global variable in controller cakephp 2

泄露秘密 提交于 2019-12-01 08:10:39
What's the way to have a global variable inside a controller? I have tried to do it using beforeFilter but it is not accessible from the others functions. Can it only be done using Configure::read and Configure::write you can set variable accessible in any controller in your AppController class AppController extends Controller { public $myGlobalVar; public function beforeFilter() { //this can be anything array, object, string, etc ..... $this->myGlobalVar = "test2"; } } then in your other controller you can access variable anywhere like this class TestController extends AppController { public

Ocasional error warning when CakePHP is writing to the cache

心不动则不痛 提交于 2019-11-30 20:59:32
I'm developing a CakePHP 2.2 site locally with MAMP. Every so often, I get one or more warnings similar to this, about not being able to write to one or more cache files: Warning: SplFileInfo::openFile(/Applications/MAMP/htdocs/mywebsite/www/app/tmp/cache/persistent/myapp_cake_core_cake_console_en-au): failed to open stream: Permission denied in /Applications/MAMP/htdocs/mywebsite/www/lib/Cake/Cache/Engine/FileEngine.php on line 313 The weird thing is, /tmp is 777, tmp/cache is 777, and tmp/cache/persistent is 777 (don't worry... it won't be 777 on the server!). The file itself inside tmp

CakePHP 2.2.2 not working on Windows IIS7

半城伤御伤魂 提交于 2019-11-30 20:07:36
问题 I am trying to make CakePHP work over windows with IIS7 and i can not get it following the official documentation: http://book.cakephp.org/2.0/en/installation/advanced-installation.html#url-rewrites-on-iis7-windows-hosts I have downloaded the rewrite module for IIS7 from here: http://www.microsoft.com/en-us/download/details.aspx?id=7435 And then installed it as admin. I created the web.config file inside my cakephp main folder as said on the documentation. The result I'm having is that when i

Using Model in routes file, cakephp

允我心安 提交于 2019-11-30 15:48:31
I am looking to load values from my database in my /app/Config/routes.php configuration file. At the top I am using: App::uses('Option', 'Model'); And I am calling my find in my class: $this->Option->find('all'); Am I missing something? I think you have to instantiate the model before you use it: App::uses('Option', 'Model'); $option = new Option(); $something = $option->find('all'); I wouldn't put any database queries in Routes. It's not the place for them (separation of concerns etc). It will also slow down every request and the routes shouldn't be changing all that frequently. What I've

CakePHP controller alias

落花浮王杯 提交于 2019-11-30 15:27:36
I know there are a couple of other topics about this subject, but non of them seems to fit my needs. What I have example.com/log/ LogsController.php I have LogsController instead of LogController (plural) because CakePHP wants you to have controllers in plural. But as you might know/notice, example.com/log/ will never use LogsController because of the missing 's' in the url. Now, I want to have /log/* being redirected to /logs/* . Works perfectly fine with the following code: Router::connect ('/log/*', array('controller'=>'logs')); But, when I try to access example.com/log/actions/foo/bar it

Ocasional error warning when CakePHP is writing to the cache

只愿长相守 提交于 2019-11-30 05:02:46
问题 I'm developing a CakePHP 2.2 site locally with MAMP. Every so often, I get one or more warnings similar to this, about not being able to write to one or more cache files: Warning: SplFileInfo::openFile(/Applications/MAMP/htdocs/mywebsite/www/app/tmp/cache/persistent/myapp_cake_core_cake_console_en-au): failed to open stream: Permission denied in /Applications/MAMP/htdocs/mywebsite/www/lib/Cake/Cache/Engine/FileEngine.php on line 313 The weird thing is, /tmp is 777, tmp/cache is 777, and tmp

Using Model in routes file, cakephp

拟墨画扇 提交于 2019-11-29 23:35:34
问题 I am looking to load values from my database in my /app/Config/routes.php configuration file. At the top I am using: App::uses('Option', 'Model'); And I am calling my find in my class: $this->Option->find('all'); Am I missing something? 回答1: I think you have to instantiate the model before you use it: App::uses('Option', 'Model'); $option = new Option(); $something = $option->find('all'); 回答2: I wouldn't put any database queries in Routes. It's not the place for them (separation of concerns

CakePHP controller alias

落爺英雄遲暮 提交于 2019-11-29 21:45:10
问题 I know there are a couple of other topics about this subject, but non of them seems to fit my needs. What I have example.com/log/ LogsController.php I have LogsController instead of LogController (plural) because CakePHP wants you to have controllers in plural. But as you might know/notice, example.com/log/ will never use LogsController because of the missing 's' in the url. Now, I want to have /log/* being redirected to /logs/* . Works perfectly fine with the following code: Router::connect