Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>The original question</h2> <p>The first part, about the URLs is something called: Routing or Dispatching. There is quite good <a href="http://symfony.com/doc/current/book/routing.html" rel="noreferrer">article</a> about it in relationship with Symfony 2.x, but the the idea behind it is what matters. Also, you might looks at ways how other frameworks implement it.</p> <p>As for your original URL examples, galleries will be stored in DB. Won't they? And they will have a <strong>unique</strong> ID. Which makes this, <code>/backend/projects/edit/5/gallery/2</code> quite pointless. Instead your URL should look more like:</p> <pre><code>/backend/gallery/5/edit // edit gallery with ID 5 /backend/project/3 // view project with ID 3 /backend/galleries/project/4 // list galleries filtered by project with ID 4 </code></pre> <p>The URL should contain only the information you <strong>really</strong> need.</p> <p>This also would indicate 3 controllers:</p> <ol> <li>single gallery management</li> <li>single project management</li> <li>dealing with lists of galleries</li> </ol> <p>And the example URLs would have pattern similar to this: </p> <pre><code>/backend(/:controller(/:id|:page)(/:action(/:parameter))) </code></pre> <p>Where the <code>/backend</code> part is mandatory, but the <code>controller</code> is optional. If controller is found , then <code>id</code> ( or page, when you deal with lists ) and <code>action</code> is optional. If action is found, additional <code>parameter</code> is optional. This structure would let you deal with majority of your routes, if written as a regular expression.</p> <h2>OOP beyond classes</h2> <p>Before you start in on using or writing some sort of PHP framework, you should learn how to write proper object oriented code. And that does not mean "know how to write a class". It <em>means</em>, that you have to actually understand, what is object oriented programming, what principles it is based on, what common mistakes people make and what are the most prevalent misconceptions. Here are few lecture that might help you with it: </p> <ul> <li><a href="http://www.youtube.com/watch?v=4F72VULWFvc" rel="noreferrer">Inheritance, Polymorphism, &amp; Testing</a></li> <li><a href="https://vimeo.com/21173483" rel="noreferrer">Advanced OO Patterns</a> <sup>(<a href="http://qafoo.com/talks/11_02_phpuk_advanced_oo_patterns.pdf" rel="noreferrer">slides</a>)</sup></li> <li><a href="http://www.youtube.com/watch?v=wEhu57pih5w" rel="noreferrer">Unit Testing</a></li> <li><a href="http://www.infoq.com/presentations/principles-agile-oo-design" rel="noreferrer">The Principles of Agile Design</a></li> <li><a href="http://www.youtube.com/watch?v=-FRm3VPhseI" rel="noreferrer">Global State and Singletons</a></li> <li><a href="http://www.youtube.com/watch?v=RlfLCWKxHJ0" rel="noreferrer">Don't Look For Things!</a></li> <li><a href="https://vimeo.com/21145583" rel="noreferrer">Beyond Frameworks</a> <sup>(<a href="http://www.slideshare.net/stuartherbert/beyond-frameworks" rel="noreferrer">slide</a>)</sup></li> <li><a href="https://vimeo.com/20610390" rel="noreferrer">Agility and Quality</a> <sup>(<a href="http://www.slideshare.net/sebastian_bergmann/agility-and-quality-php-uk-2011" rel="noreferrer">slides</a>)</sup></li> <li><a href="https://vimeo.com/13439458" rel="noreferrer">Clean Code I: Arguments</a></li> <li><a href="https://vimeo.com/12643301" rel="noreferrer">Clean Code III: Functions</a></li> </ul> <p>This should give you some overview of the subject .. yeah, its a lot. But is suspect that you will prefer videos over books. Otherwise, some reading materials:</p> <ul> <li><a href="http://rads.stackoverflow.com/amzn/click/1430210117" rel="noreferrer">PHP Object-Oriented Solutions</a></li> <li><a href="http://rads.stackoverflow.com/amzn/click/0201715945" rel="noreferrer">Design Patterns Explained</a></li> <li><a href="http://rads.stackoverflow.com/amzn/click/0321127420" rel="noreferrer">Patterns of Enterprise Application Architecture</a> </li> </ul> <p>You will notice that a lot of materials are language-agnostic. That's because the theory, for class-based object oriented languages, is the same.</p> <h2>P.S.</h2> <p>Be careful with <code>extends</code> keyword in your code. It means "<strong>is a</strong>". It is OK, if <code>class Oak extends Tree</code>, because all oaks are trees. But if you have <code>class User extends Database</code>, someone might get offended. There is actually an OOP principle which talks about it: <a href="http://en.wikipedia.org/wiki/Liskov_substitution_principle" rel="noreferrer">Liskov substitution principle</a> .. also there is a very <a href="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/07/liskov_substitution_principle_small.jpg" rel="noreferrer">short explanation</a></p>
 

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