Relevant

Below is a suggested structure for your project,
feel free to change the name of the directory in
the way that best suits you

Basic Structure

  • my-project
    • src
      • Controller
        • Index.php
      • view
        • index.php
    • www
      • index.php
      • .htaccess

www/.htaccess

make sure apache is installed and enable Mod_Rewrite:

$ a2enmod rewrite

Auto-load PSR-4

Let's use the PSR-4 pattern in a PHP project through the Composer dependency manager itself. In the composer.json file we configure the vendor namespace and the main folder from where the sub-namespaces will be created:

After configuring the project's namespace, run:

$ composer dump-autoload

src/view/index.php

src/Controller/Index.php

Suggestion

Manage the view layer with component Resource or any other template engine of your choice

www/index.php

URL

http://localhost/my-project/www/

Skeleton

Save time creating an MVC from scratch using skeleton to start your project from scratch
and use other components according to the application's needs
  • Rubricate
  • © 2015 -