Download the PHP package ianaldrighetti/lmmvc without Composer

On this page you can find all versions of the php package ianaldrighetti/lmmvc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lmmvc

LMMVC - Lean, Mean MVC

Build Status

LMMVC is a relatively small PHP MVC library. It allows you to route requests to a controller to handle the request based on the request URI -- pretty much like any other MVC.

What's so different about LMMVC? Well, to be honest, probably not much. While there are hundreds (or thousands, or a lot) of other MVC libraries already out there, I made this primarily for learning experience. However, I do plan on using it in my projects from here on out. I figured I would make it open source (under the MS-RL), that way I could have a central location to keep it updated.

Just like most other MVC's, the URL's are formatted like so:

With LMMVC's default setup, this would load a controller with a class name of ControllerName and invoke method_name. id and code would be accessible through $_GET, as usual.

Installation

You can get the latest on our release page, or you can clone it, or even use composer. To use this package via composer, add this to your require:

Basic Setup

For a basic setup you can checkout the directory in the repository. There it has an example .htaccess, example index.php and example controller. The example index.php goes over the basics of the methods that are useful to someone setting up their application. However, for more detailed documentation, you can look below.

Usage

All you need to do is create a class that implements the \LmMvc\BaseController interface, like so:

That's your basic controller right there.

Note: LMMVC will not allow users to access private, protected or static methods. Any method that is to be accessible by the outside world must be marked as public.

Method Arguments

A small feature in LMMVC is that methods in controllers can specify arguments, these arguments would then be fetched from , if available.

For example, a method like so:

The above would be passed , and . In the event that these are not found and the parameter sets to default, it will be passed null. If any variable is not found in and it does have a default, the default will be passed.

Arguments may be type hinted with an array, and if in the example wasn't found, an empty array would be supplied. However, if was not actually an array, LMMVC would convert it to an array (with the entry set to ).

Application Documentation

The following is documentation for every method in the Application class.

setControllerCaser

The controller caser is very important to LMMVC. Because LMMVC relies on autoloading for loading the controllers at runtime the controller name must be properly cased in order for autoloading to work (as it is often case-sensitive).

To set a controller caser, you can do one of the following:

LMMVC provides a class with static methods that offer some common casings for controller names. These are all in the \LmMvc\Utility\ControllerCaser class:

LMMVC defaults to ControllerCaser::camelCaseWithFirstUpper. Additionally, if you use camel casing that means your actual controller name (i.e. in the source file) cannot have an underscore. That's because they are used when parsing the controller name to determine the character to uppercase.

These controller casers can throw Exception's as well in the case that the controller name cannot be processed. For example, the camelCase methods in ControllerCaser throw an Exception if there is more than one underscore in a row. But there is no need to throw an Exception if the controller name has an invalid character for a controller class name, as it is validated first using the method first.

setExceptionHandler

An exception handler must be an instance of a class that implements the \LmMvc\ExceptionHandler class. The exception handler is used to handle, as it's name implies, exceptions. These exceptions include PageNotFoundException, MalformedUriException and ControllerException -- those are all exceptions that LMMVC can throw at some point. It must also handle every other exception as well, including those possibly thrown by a controller. As usual, LMMVC comes with a default exception handler, called \LmMvc\DefaultExceptionHandler.

However, if you wish to have a custom one, you simply set it by calling up:

setNamespace

As noted numerous times, LMMVC relies on autoloading to load a controller at runtime once the proper controller name has been determined. In order to accomplish this (well, to do it properly) you must tell LMMVC where the controllers reside, their namespace. This is done like so:

This will make LMMVC try to autoload a controller by the name of my_controller (which becomes MyController with the default casing setup) from: .

setDefaultController

If no controller name can be determined from the request URI (i.e. or ), LMMVC must be told what controller to use by default, like so:

Note, as above, that this is not the actual name of the controller in it's implementation, but the controller name that would appear in the URL based on the controller casing being used. For example, with default controller casing would be specified as .

run

After everything is setup, simply call:

This will cause the routing to occur and your application (if setup right) will work. It's that easy!

Other Methods

There are other publicly accessible methods in the Application class, however they are just there for testing purposes. You can always take a look at the documentation for those other methods in the source, though.


All versions of lmmvc with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ianaldrighetti/lmmvc contains the following files

Loading the files please wait ....