Download the PHP package pyrsmk/lumy without Composer

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

Lumy 2.9.3

Lumy 2 repository is now unmainted in favor of Lumy 3. This new version is a big turn since the whole framework has been replaced by Slim. We just kept a little wrapper around Slim to be able to use Chernozem too.

Lumy is a minimal micro CLI/HTTP framework that aims to be quick, effective and simple to extend as you want with any external component. It is heavily based on Chernozem to provide an efficient way for dependencies injection.

Lumy is born with the fact that micro-frameworks, like Silex or Slim, are still too big and handle behaviors that can be managed by many existing libraries. They're often too web-oriented too : PHP is also great with CLI environment.

It is shipped with a CLI/HTTP router, environment objects and a middleware stack.

Install

Pick up the source or install it with Composer :

If you're not installing it with Composer, don't forget to load its dependencies too : Chernozem, LongueVue.

A quick example

Basics

The Lumy object is a singleton and can be retrieved/instantiated with :

Adding CLI routes

The basic way to add a route in a CLI environment is :

We can specify an array of route chains :

Since the routing system is based on LongueVue, we can use slugs to extract options :

There're cases where we need to verify if the command syntax is valid. We can achieve it by using regexes to validate the command. If the specified regex does not match the route neither :

There're also some other cases where we want to have a default value from some of our slugs :

Adding routes with HTTP environment

HTTP routes work the same as in CLI context but the route() method has been replaced in favor of get(), post(), put() and delete(). Here's some examples to clarify the situation :

Please note that PUT and DELETE requests work like the POST request. Their data will be available from the $_POST[] array. If you need to add a custom route, use the map() method :

The HTTP context adds some new constants to ease the writing of routes :

If needed, you can assemble an URL using a predefined route :

As you may already guess, the HTTP context makes REST requests. But the PUT and DELETE requests are not supported in HTML. So, to know which request is sent, Lumy watch the $_POST['_METHOD'] variable for the method to use. Add an <input name="_METHOD" value="DELETE"> in your form. There's also a library that simplifies the whole thing by making synchroneous REST requests on-the-fly.

Registering custom values and services

Since Lumy is built on top of Chernozem (we advise you to read its documentation), it supports variables containing and, more interesting, services :

Now, when the service is retrieved, the Session object is automatically instantiated. It permits us to only load objects that we really want for the requested page to render.

Middlewares

In Lumy, we're using middlewares to modularize applications. Each middleware is a simple closure/callback that is called at run time one by one, in the order they're defined. Each middleware need to call the next middleware itself, it permits to wrap all middlewares in one function. When Lumy is run, a middleware is automatically created to run routing functions. Then, keep in mind that you can wrap the entire application with any middleware.

Handling errors

The error handler is defined by the error() method which takes a callback :

Run the application

When you're good you can :

The request object

All request objects have a getChain() method that returns the whole request/command chain for the request. You can retrieve this object with $lumy['request'].

CLI

The CLI request object is pretty concise. It implements two methods to deal with the command chain (the following examples are based on the myapp install install/path/ command) :

HTTP

The HTTP request object implements several useful functions to deal with HTTP requests (the following examples are based on the http://mywebsite.com/app/gallery/7 request) :

The response object

Response objects implement 4 methods for managing the response body. You can retrieve this object with $lumy['response'].

It also implements a __toString() function to print directly the response object returned by Lumy when the application has runned :

Here's how we're managing the response body :

CLI

The CLI response object has methods for setting/getting environment variables and set ANSI colors :

For convenience, this response object is shipped with constants for ANSI codes you can use with colorize() :

HTTP

The HTTP response object can manage headers, status code and provide some useful functions to deal with the browser :

Public directories

Since we often encounter several different servers in one project (at least, your local and remote ones), Lumy has like a firewall option that allow or forbid access to your files if needed. Point all requests in your .htaccess (or whatsoever) to your application file (index.php) : now all requets are passing through Lumy. We just need to allow/deny what we need.

Advanced use of routes

The routing mechanism is used internally and we generally don't have to bother about it, otherwise there's some cases where we want to deal with routes directly. For that, we should name our routes by passing a name as the last argument of route(), get(), post(), etc :

Then you can get the route with $lumy['router']['gallery'] and access to the following methods :

License

Lumy is published under the MIT license.


All versions of lumy with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
ext-fileinfo Version *
pyrsmk/chernozem Version 3.*
pyrsmk/longuevue Version 0.*
pyrsmk/funktions Version ^0.1.6
beatswitch/lock Version ^0.2.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 pyrsmk/lumy contains the following files

Loading the files please wait ....