Download the PHP package lucinda/abstract_mvc without Composer

On this page you can find all versions of the php package lucinda/abstract_mvc. 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 abstract_mvc

Abstract MVC API

Table of contents:

About

This API is a skeleton (requires binding by developers) created to contain parts of a MVC API that do not relate to STDIN type (console, url request or exception to be handled). It serves as a foundation for:

API is fully PSR-4 compliant, only requiring PHP8.1+ interpreter and SimpleXML extension. To quickly see how it works, check:

All classes inside belong to Lucinda\MVC namespace!

Configuration

To configure this API you must have a XML with following tags inside:

  • application: (mandatory) configures your application on a general basis
  • resolvers: (mandatory) configures formats in which your application is able to resolve responses to
  • routes: (mandatory) configures routes that bind requested resources to controllers and views

Application

Maximal syntax of this tag is:

Where:

  • application: (mandatory) holds settings to configure your application based on attributes and tag:
    • default_format: (mandatory) defines default display format (extension) for your application.
      Must match a format attribute in resolvers!
    • default_route: (mandatory) defines implicit route when your application is invoked with none.
      Must match a id attribute in routes!
    • version: (optional) defines your application version, to be used in versioning static resources.
    • paths: (optional) holds where core components used by API are located based on attributes:
      • views: (optional) holds folder in which user-defined views will be located (if HTML)

Tag example:

Resolvers

Base syntax of this tag is:

Where:

  • resolvers: (mandatory) holds settings to resolve views based on response format (extension). Holds a child for each format supported:
    • resolver: (mandatory) configures a format-specific view resolver based on attributes:
      • format: (mandatory) defines display format (extension) handled by view resolver.
        Example: "html"
      • content_type: (mandatory) defines content type matching display format above.
        Example: "text/html"
      • class: (mandatory) name of user-defined PS-4 autoload compliant class (including namespace) that will resolve views.
        Must be a ViewResolver instance!

Tag example:

Routes

Maximal syntax of this tag is:

Where:

Tag example:

Binding Points

In order to remain flexible and achieve highest performance, API takes no more assumptions than those absolutely required! It offers developers instead an ability to bind to its prototypes via XML:

XML Attribute @ Tag Class Prototype Ability Gained
controller @ route Runnable MVC controller for any STDIN type
class @ resolver ViewResolver Resolving response in a particular format (eg: html)

Programmatic Binding

It offers developers an ability to bind programmatically to its prototypes via FrontController constructor:

Class Prototype Ability Gained
ErrorHandler (mandatory) Handler to use if a \Throwable while API handles request into response

Unit Tests

For tests and examples, check following files/folders in API sources:

Reference Guide

These classes are fully implemented by API:

Following abstract classes require to be extended by developers in order to gain an ability:

Class Application

Class Application encapsulates information detected from XML and defines following public methods relevant to developers:

Method Arguments Returns Description
getVersion void string Gets application version based on version attribute @ application XML tag
getTag string $name \SimpleXMLElement Gets a pointer to a custom tag in XML root

Other public methods are relevant only to APIs built on top of this.

Class Application Route

Class Application\Route encapsulates information detected from matching route XML tag and defines following public methods:

Method Arguments Returns Description
getID void string Gets route unique identifier based on value of id XML attribute
getController void string Gets controller class name/path/namespace based on value of controller XML attribute
getFormat void string Gets custom route-specific display format based on value of format XML attribute matching a format attribute of resolver XML tag
getView void string Gets view path based on value of view XML attribute

Class Application Format

Class Application\Format encapsulates information detected from matching resolver XML tag and defines following public methods:

Method Arguments Returns Description
getName void string Gets reponse format (extension) based on value of format XML attribute
getCharacterEncoding void string Gets response character encoding based on value of charset XML attribute
getContentType void string Gets response content type based on value of content_type XML attribute
getViewResolver void string Gets view resolver class based on value of class attribute

To better understand how views will be resolved in the end, check How Are Views Resolved documentation below!

Class Response

Class Response encapsulates operations to be used in generating response. It defines following public methods relevant to developers:

Method Arguments Returns Description
getBody void string Gets response body saved by method below.
setBody string $body void Sets response body.
getStatus void Response\Status Gets response http status saved by method below.
setStatus Response\HttpStatus void Sets response http status and splits it into id and description
headers void array Gets all response http headers saved by methods below.
headers string $name ?string Gets value of a response http header based on its name. If not found, null is returned!
headers string $name, string $value void Sets value of response http header based on its name.
view void Response\View Gets a pointer to view encapsulating data based on which response body will be compiled

When API completes handling, it will call commit method to send headers and response body back to caller!

Class Response Status

Class Response\Status encapsulates response HTTP status and defines following public methods relevant to developers:

Method Arguments Returns Description
getId void int Gets http response status id (eg: "304")
getDescription void string Gets http response status description (eg: "not modified").

Class Response View

Class Response\View implements \ArrayAccess and encapsulates template and data that will later be bound to a response body. It defines following public methods relevant to developers:

Method Arguments Returns Description
getFile void string Gets location of template file saved by method below.
setFile string int Sets location of template file to be used in generating response body.
getData void array Gets all data that will be bound to template when response body will be generated.

By virtue of implementing \ArrayAccess, developers are able to work with this object as if it were an array:

Class Response Redirect

Class Response\Redirect is a Runnable that encapsulates http status 301/302 redirection with its options. It defines following public methods relevant to developers:

Method Arguments Returns Description
__construct string $location void Sets location to redirect to (by default redirection will be permanent and cacheable).
setPermanent bool $flag void Sets whether redirection is permanent.
setPreventCaching bool $flag void Sets whether browsers should prevent caching redirection.
run - void Performs redirection and exits code.

Example:

Interface Runnable

Interface Runnable interface it implements, class comes with following public method:

Method Arguments Returns Description
run void Executes component logic

Usage example:

https://github.com/aherne/lucinda-framework/blob/master/src/Controllers/SecurityPacket.php

Abstract Class ViewResolver

Abstract class ViewResolver implements Runnable and encapsulates conversion of Response\View to response body for final response format.

Developers need to implement run method for each resolver, where they are able to access following protected fields injected by API via constructor:

Field Type Description
$application Application Gets application information detected from XML.
$response Response Gets access to object based on which response can be manipulated.

Usage example:

https://github.com/aherne/lucinda-framework/blob/master/src/ViewResolvers/Html.php

In order to better understand how view resolvers work, check How Are View Resolvers Located section below!

Specifications

Since this API is a skeleton to build MVC APIs on top it comes with a series of specifications that may or may not be automatically implemented here:

How Is Response Format Detected

To better understand how default_format and default_route attributes in resolvers tag, let's take this XML for example:

There will be following situations for above:

If Route Detected Then Format Detected Description
index html Because no specific format is set, value of default_format is used
users html Because no specific format is set, value of default_format is used
blog json Because route detected has format its value is used

This logic requires to be implemented by child APIs because the nature of resolvers differs based on STDIN type!

How Are Views Resolvers Located

To better understand how default_format attribute in resolvers tag, let's take this XML for example:

In that case if "psr-4" attribute in composer.json associates "Lucinda\Project\" with "src/" folder then:

This logic is entirely implemented by this API! Developers only need to plug in suitable ViewResolver classes in XML.

How Is Route Detected

To better understand how default_route attribute in routes tag, let's take this XML for example:

Assuming STDIN comes from HTTP requests, there will be following situations for above:

If Request Is Then Route ID Detected Description
/ index Because no specific page was requested, that identified by default_route is used
/blog blog Because page is routed, that whose id matches request is used

This logic requires to be implemented by child APIs since logic of request depends on STDIN type!

How Are Controllers Located

To better understand how default_route attribute in routes tag, let's take this XML for example:

In that case if "psr-4" attribute in composer.json associates "Lucinda\Project\" with "src/" folder then:

As you can see above, controller namespace was ommitted because controller itself must be implemented by child APIs (since it depends on STDIN type).

How Are Views Located

To better understand how views attribute in routes tag, let's take this XML for example:

In that case if route "user/info" matches STDIN request then:

As you can see above, view extension was ommitted because view itself must be implemented by child APIs (since it depends on STDIN type).


All versions of abstract_mvc with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1|^8.0
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 lucinda/abstract_mvc contains the following files

Loading the files please wait ....