Skip to content

carli2/picomvc-skeleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PicoMVC PHP Framework

PicoMVC is a minimalistic PHP framework intended for PHP programmers who want to write clean code without being forced to adjust their brains to a big framework which restricts them.

Components

PicoMVC only consists of a templating engine. The engine is completely object oriented and renders a surrounding template as well as nested template snippets.

Directory Structure

  • *.php all controllers you want to write. Take index.php as a reference.
  • view.php the template engine
  • db.php the database engine
  • conf.php.dist the default config (copy to conf.php in deployment)
  • js/ for your javascript
  • css/ for your style sheets
  • img/ for your images
  • view/ your template snippets
  • view/layout.phtml the layout of all pages

Usage

Business Logic API

Create a file api.php that requires db.php, create a class that extends DB, overwrite the function protected performUpdates(&$current_version) (complete guide at db.php) and add all public API functions you want to add to the business logic. Refer to $this->sql as the mysqli object.

Controllers and views

You basically write controllers as php files that require 'view.php', do some logic and then instanciate a View object, fill in the fields and call render(). Set View->template to a script in view/ and implement all rendering routines there while the logic stays in the controllers.

Telling the view to render users/edit means it will render the file view/users/edit.phtml. Insert your HTML code into that file and access the $this object from PHP in order to access the fields set by the controller. Render inner views by calling $this->render('viewname') or creating a new View object and calling render(). The second version is better since it encapsulates data e.g. for loops.

If you want to use database support, create a new file, require 'db.php', create a class that inherits from DB and override performUpdates(). Then, whenever you need the database, create an instance of your new class. Use MyClass::getInstance(). Put all database related functions into your class.

Getting Started

Just clone the git repository into a folder and start adding the API, controllers and views.

git clone https://github.com/carli2/picomvc-skeleton

Star and watch this repository if you like the idea of a lightweight clean framework for small and big projects.

About

PicoMVC PHP Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published