久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

CakePHP 控制器別名

CakePHP controller alias(CakePHP 控制器別名)
本文介紹了CakePHP 控制器別名的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我知道關(guān)于這個(gè)主題還有其他幾個(gè)主題,但似乎沒有一個(gè)適合我的需要.

I know there are a couple of other topics about this subject, but non of them seems to fit my needs.

我有什么

  • example.com/log/
  • LogsController.php

我有 LogsController 而不是 LogController(復(fù)數(shù)),因?yàn)?CakePHP 希望你有復(fù)數(shù)的控制器.

I have LogsController instead of LogController (plural) because CakePHP wants you to have controllers in plural.

但您可能知道/注意到,example.com/log/ 永遠(yuǎn)不會(huì)使用 LogsController,因?yàn)榫W(wǎng)址中缺少s".

But as you might know/notice, example.com/log/ will never use LogsController because of the missing 's' in the url.

現(xiàn)在,我希望將 /log/* 重定向到 /logs/*.使用以下代碼可以正常工作:

Now, I want to have /log/* being redirected to /logs/*. Works perfectly fine with the following code:

Router::connect ('/log/*', array('controller'=>'logs'));

但是,當(dāng)我嘗試訪問 example.com/log/actions/foo/bar 時(shí),它似乎不起作用.所以經(jīng)過一些谷歌搜索后,我發(fā)現(xiàn)了這個(gè):

But, when I try to access example.com/log/actions/foo/bar it doesn't seem to work. So after some Googeling I found this:

Router::connect ('/log/:action/*', array('controller'=>'logs'));

效果很好.但是現(xiàn)在當(dāng)我再次嘗試訪問 example.com/log/時(shí),它說

Works great. But now when I'm trying to access example.com/log/ again, it says

錯(cuò)誤:找不到 LogController.

Error: LogController could not be found.

問題所以我的問題是,如何為我的 url 設(shè)置別名,以便 /log/ 將使用 LogsController 而不是嘗試使用 LogController.

Question So my question is, how do I set up an alias for my url so that /log/ will use LogsController instead of trying to use LogController.

我還有幾個(gè)控制器想要改變它,比如 flight =>FlightsController, profile =>ProfilesController.

I have a few more Controllers where I'd like to change this, like flight => FlightsController, profile => ProfilesController.

看看這個(gè)問題.這是關(guān)于相同的主題,但略有不同.它可能會(huì)以某種方式幫助您.

Have a look at this question. It is about the same subject, but slightly different. It might help you in some way.

推薦答案

好的,在 IRC 上其他一些人的幫助下,諸如此類.我發(fā)現(xiàn)了以下內(nèi)容.

Ok, with the help of some other people on IRC and stuff like that. I found out the following.

組合

Router::connect('/flight/:action/*', array('controller'=>'flights'));
Router::connect('/flight/*', array('controller'=>'flights'));

可以解決問題.我以前試過這個(gè),但按其他順序,像這樣:

does the trick. I tried this before, but in a other order, like so:

Router::connect('/flight/*', array('controller'=>'flights'));
Router::connect('/flight/:action/*', array('controller'=>'flights'));

這不起作用.

所以這篇文章的前兩行代碼為我解決了這個(gè)問題.另一個(gè)人告訴我 Arun Jain 的解決方案不是一個(gè)合適的解決方案,因?yàn)樗哺淖兞撕诵闹械拿Q約定.這會(huì)導(dǎo)致 FormsHelper 和類似的類出現(xiàn)問題.所以我想我會(huì)更喜歡這篇文章中的代碼,因?yàn)檫@只是一個(gè)別名,而不是一個(gè)核心更改腳本.無(wú)論如何,感謝您的幫助.

So the first 2 lines of code in this post solved it for me. Another guy told me that the solution of Arun Jain isn't a proper solution, because it changes the nameconventions in the core as well. Which will cause problems with the FormsHelper and classes like that. So I think I will prefer the code in this post since this is just an alias instead of a core changing piece of script. Thanks for the help anyway.

這篇關(guān)于CakePHP 控制器別名的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Session is lost after an OAuth redirect(OAuth 重定向后會(huì)話丟失)
Pagination Sort in Cakephp 3.x(Cakephp 3.x 中的分頁(yè)排序)
CakePHP Shared core for multiple apps(CakePHP 多個(gè)應(yīng)用程序的共享核心)
Login [ Auth-gt;identify() ] always false on CakePHP 3(在 CakePHP 3 上登錄 [ Auth-identify() ] 始終為 false)
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 87 bytes)(致命錯(cuò)誤:允許的內(nèi)存大小為 134217728 字節(jié)已用盡(嘗試分配 87 字節(jié)))
主站蜘蛛池模板: 日韩一区二区av | 日韩精品在线看 | 国产精品99久久久久久久久久久久 | 日本久草 | 99热激情| 九热在线 | 国产午夜精品久久 | 日韩欧美国产一区二区三区 | 成人国内精品久久久久一区 | 久久免费观看一级毛片 | 视频一区在线观看 | 一区二区三区小视频 | 欧美一级做a爰片免费视频 国产美女特级嫩嫩嫩bbb片 | 国产精品久久久久久久久久久免费看 | 日韩at| 日韩aⅴ片 | 亚洲成人精品国产 | 亚洲一区日韩 | 亚洲综合色婷婷 | 欧美激情视频网站 | 男女羞羞视频在线看 | 91精品国产综合久久精品图片 | 日韩无 | 国产欧美精品 | 99久久免费精品 | 久热m3u8| 91不卡| 天天干com| 国产美女精品视频 | 男女羞羞视频在线 | 欧美xxxx在线| 欧美日韩一区二区三区视频 | 成人精品久久 | 成人福利网站 | 国产成人99久久亚洲综合精品 | 久久久久久久久国产精品 | 欧美日韩精品亚洲 | 视频一区二区三区在线观看 | 黄色大片在线视频 | 亚洲444kkkk在线观看最新 | 亚洲欧洲精品一区 |