title: PHP - MVC - Better way to prevent calling unwanted method in Controller?
body: <p>I don't know if my question should be asked <a href="http://programmers.stackexchange.com">here</a> or not. Please let me know or move it/delete it if that is the case.</p>
  
  <p><strong>Question:</strong></p>
  
  <p>For the sake of learning, I'm making my own little MVC "library" for a very small personal website. Here is the process being used (please correct me if I'm not even close to doing it the right way):</p>
  
  <ul>
  <li>All requests (except images, etc.) get sent through index.php (boostrap file).</li>
  <li><p>The bootstrap file parses the request and extracts the controller and action, ex:</p>
  
  <p><a href="http://www.Domain.com/Controller/Action/Argument1/Argument2/" rel="nofollow">http://www.Domain.com/Controller/Action/Argument1/Argument2/</a>...</p></li>
  </ul>
  
  <p>Where Controller is the controller, action is the method called on the controller. In this case, it would end up being: <strong>Controller</strong>-><strong>Action</strong> ( <strong>Argument1</strong>, <strong>Argument2</strong> );</p>
  
  <p>Now, what if a user visits:</p>
  
  <pre><code>http://www.Domain.com/Controller/__destruct
  </code></pre>
  
  <p>or</p>
  
  <pre><code>http://www.Domain.com/Controller/__get/password
  </code></pre>
  
  <p><strong>Current solution(s):</strong></p>
  
  <ul>
  <li>Run the request through a $config->getURIFilter () method or something</li>
  <li>Do a check for method_exists () and is_callable (), etc.</li>
  <li>Don't have any methods in the controller that aren't for handling a request</li>
  </ul>
  
  <p><strong>It just seems like this shouldn't be an issue to begin with and my design is wrong.</strong></p>
  
  <p><strong>P.S.</strong> I've already looked at plenty of good MVC PHP frameworks (CodeIgniter, Yii, CakePHP, Zend, Swiftlet, etc.)</p>