Jump problems when cakephp is deployed on SAEs

Source: Internet
Author: User
Tags tmp file
This post is edited by jianghu52 at 11:25:41.

Sae cakephp jump

Cakephp was deployed on SAEs. as a result, I didn't even handle the basic jump. I really failed. I had to come here for advice.
I tested the same code locally and it is easy to use, but it won't work if I deploy it on SAEs. The code snippet is as follows:
AppController. php:
AppController extends Controller {public function beforeFilter () {parent: beforeFilter (); $ current_ctl = strtolower ($ this-> name); if ($ current_ctl = 'page ') {// If The echo breakpoint is set, $ this-> redirect (array ('controller' => 'test ', 'action' => 'index '));}}}


TestController. php:
Class TestController extends AppController {var $ name = 'test'; var $ uses = Array (''); public function index () {/* here echo breakpoint is useless, I initially suspected it was a case-insensitive problem, but I have tried many times, such as the name of the file with underscores (_), No underscores (_), upper-case letters (_), and lower-case letters. Changing the name to Test and declaring that the name is public is invalid */$ this-> set ('cn', 'Chinese test ');}}


Index. ctp:
 


Normally displayed on the local machine, but the sae is blank. I don't know why. Really strange.


Reply to discussion (solution)

Do you want to write a disk for this framework? If you want it, you cannot use it.

I understand what you mean, because the default cakephp is used to write the tmp file of the app, but sae does not support file writing, so if you do not change anything, it will cause problems. I transplanted a version and wrote all the files to be written by cake in Memcache. Therefore, it can run smoothly.
I have uploaded the code to github.
Https://github.com/jianghu52/sae_cakephp_sample. If this package is directly uploaded to sae, you can open the home page. But the problem is. I have no way to redirect
I wrote a jump method in pagecontroller [$ this-> redirect (array ('controller' => 'test', 'Action' => 'index ')); ]. The format shown on sae is that the address bar displays [http: // ** .sinaapp.com/test.pdf ]. The error message "The requested URL/test was not found on this server." is displayed .]. That is to say, the controller I wrote is not parsed. I don't know where the problem is.

After studying for a long time, I finally figured out one thing. I am not familiar with the file system of sae.
In the original framework, only sae_app_wizard.xml exists, but the config. yaml file does not exist. Therefore, the redirect redirection still requests content from the tmp package in the app and fails. Added the config. yaml file and added the following two sentences.

handle:  - rewrite:if (!is_file() && !is_dir() && path ~ "^app/webroot/(.*)") goto "app/webroot/index.php?url=$1&%{QUERY_STRING}"  - rewrite:if (!is_file() && !is_dir() && path ~ "(.*)") goto "app/webroot/$1?%{QUERY_STRING}"

You can achieve the jump.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.