title: How to add a new url route to an existing CakePHP (2) project
body: <p>A client of mine has a legacy CakePHP2 website which needs updating with a new page to produce a PDF and I'm really struggling to get the new method within the Controller to be called.</p>
  <p>I have a lot of experience with PHP but I've not used it a great deal in the last five years and I've never touched CakePHP. The site was maintained by someone else but they asked me to take a look since that person has left.  I know the site is running a very old  version of Cake, which I've told them, but they don't want it updated at this point as it's being replaced anyway.</p>
  <p>I've gone through the CakePHP Docs for v2 but my clients routes.php file does not seem to match up to the wildcard paths suggested in the docs.</p>
  <p>The entry in routes.php that routes to several existing methods is:</p>
  <p><code>Router::connect('/', array('controller' =&gt; 'surveys', 'action' =&gt; 'index'));</code></p>
  <p>I've then edited the Controller/SurveysController.php file to add in a new method so I could perform a simple test.</p>
  <pre class="lang-php prettyprint-override"><code>    public function pdf($id, $type = 1) {
          file_put_contents(&quot;/tmp/debug.log&quot;, &quot;inside the new method&quot;);
          // Call an existing method just to load a page
          $this-&gt;report($id);
  </code></pre>
  <p>I've copied the existing <code>Views/Survey/report.ctp</code> file to <code>Views/Survey/pdf.ctp</code> so, in theory, the method should be taking the same action and the view/template will also be the same.</p>
  <p>The issue I have though is whilst I can browse to the existing URL of <code>surveys/report/123</code> if I try going to the new methods URL of <code>surveys/pdf/123</code> I am simply HTTP302  redirected to the websites index. The file I try to create within the view is not being created but as I'm not seeing a 404 page such as if I went to <code>/surveys/invalid-url/123</code> I don't really understand what's happening.</p>
  <p>To make things worse I can't the site running locally due to all the legacy dependencies it uses not being compatible with my current dev machine.</p>
  <p>From what I understand of CakePHP creating the new method and new .ctp file should be all I need to do in order to allow the page to work but there's obviously something I have missed.</p>
  <p>Hoping some fellow S/O users can point me in the right direction as to where I am going wrong.</p>
  <p><strong>update</strong>
  The default routes are being added as they still have this in place:</p>
  <p><code>require CAKE . 'Config' . DS . 'routes.php';</code></p>
  <p>They are using the [ACL from the docs][1] with AclExtras being installed but when I run  <code>./Console/cake AclExtras.AclExtras aco_update</code>  they receive an error.</p>
  <pre><code>Error: Class QuestionsControllerDec2017 does not exist
  </code></pre>
  <p>There are a lot of files and folders that I can see that have dates in the names which I assume are older backups.  Is this now causing a problem with the reflection picking them up?</p>
  <p>I'd edited Controller/UsersControllers.php to add in a an entry for the new method</p>
  <pre><code>    $this-&gt;Acl-&gt;allow($group, 'controllers/Surveys/report');
      $this-&gt;Acl-&gt;allow($group, 'controllers/Surveys/download_report');
      // New Line below
      $this-&gt;Acl-&gt;allow($group, 'controllers/Surveys/pdf');
  </code></pre>
  <p>So is it a case that the aros_acos table is not out of date and needs an entry for this to be added but because of the previously error I can't add in dynamically.</p>
  <p>** Update 2 **
  The issue was I had missed out the permission creation so because of the legacy code access had to be created by using</p>
  <p><code>./Console/cake acl create aco Surveys pdf</code></p>