Note that there are some explanatory texts on larger screens.

plurals
  1. POYii - Controller in subdirectory
    primarykey
    data
    text
    <p>I'm facing an issue with Yii Framework routing.</p> <p>I've created controller, let's call it TestController.php</p> <p>Then, I need to put it into a subdirectory called Make, so my structure would look like:</p> <pre><code>controllers/TestController.php controllers/Make/TestController.php </code></pre> <p>Of ocurse, if I change it's name, it works perfectly but is there any way to put a controller of the same name in controllers directory and a subdirectory?</p> <p><strong>Edit</strong><br> My URLManager config looks like:</p> <pre><code>'urlManager'=&gt;array( 'showScriptName' =&gt; false, 'urlFormat'=&gt;'path', 'rules'=&gt;array( 'gii' =&gt; 'gii', 'gii/&lt;controller:\w+&gt;' =&gt; 'gii/&lt;controller&gt;', 'gii/&lt;controller:\w+&gt;/&lt;action:\w+&gt;' =&gt; 'gii/&lt;controller&gt;/&lt;action&gt;', '&lt;controller:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/view', '&lt;controller:\w+&gt;/&lt;action:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;', '&lt;controller:\w+&gt;/&lt;action:\w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;', ), ), </code></pre> <p>I have a controller <code>Bookmarks</code>. As I have some other things related to the bookmarks, I needed to create a directory <code>bookmarks</code> and put some controllers there, for example <code>Categories</code>.</p> <p>Can't force to make it work.</p> <p><strong>Edit 2</strong><br> Just checked clean application. It seems to be a Yii bug (?).</p> <p><strong>Edit 3</strong><br> I've changed import configuration, as suggested:</p> <pre><code>'import'=&gt;array( 'application.models.*', 'application.components.*', 'application.controllers.bookmarks.*' ), </code></pre> <p>I have also created a correct route rule <code>'bookmarks/&lt;controller:\w+&gt;/&lt;action:\w+&gt;'=&gt;'bookmarks/&lt;controller&gt;/&lt;action&gt;',</code>.</p> <p>My files structure is now as following:</p> <pre><code>BookmarksController.php bookmarks/CategoriesController.php </code></pre> <p>Here's an exceptions that's being thrown:</p> <blockquote> <p>exception 'CHttpException' with message 'The system is unable to find the requested action "categories".' in /home/root/www/yiitesting/framework/web/CController.php:477</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload