Download the PHP package martinjur/limo without Composer

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

Limo: README

Limo is fork of Limonade. All content below is aplicable. Instead of 'limonade' we now use 'limo'.

Limonade: README

Limonade is a PHP micro framework for rapid web development and prototyping.

It's inspired by frameworks like Sinatra or Camping in Ruby, or Orbit in Lua. It aims to be simple, lightweight and extremly flexible.

Limonade provides functions that complete the PHP basic set, while keeping consistency with native functions and sitting up on them.

Limonade is easy to learn and provides everything that you can expect from a modern framework (MVC, REST, ...)

About this document

This document provides a quick, but comprehensive, guide of Limonade features.

For more informations, you can see the website, examples, and of course the source code which is still the best documentation.

A discussion group is also available for more exchanges.

Requirements

Routes

Routes combine

So they make the glue between an URL + a HTTP method, and the code provided in a callback controller.

Routes are matched in the order they are declared. The search is performed with a path given through browser URL:

http://localhost/my_app/?u=/my/path
http://localhost/my_app/?uri=/my/path
http://localhost/my_app/index.php?/my/path
http://localhost/my_app/?/my/path

When PUT,DELETE or PATCH methods are not supported (like in HTML form submision), you can use the _method parameter in POST requests: it will override the POST method.

Routing patterns and parameters

Patterns may include named parameters. Associated values of those parameters are available with the params() function.

Patterns may also include wildcard parameters. Associated values are available through numeric indexes, in the same order as in the pattern.

Unlike the simple wildcard character *, the double wildcard character ** specifies a string that may contain a /

Pattern may also be a regular expression if it begins with a ^

Wildcard parameters and regular expressions may be named, too.

You can also provide default parameter values that are merged with and overriden by the pattern parameters.

Callback controllers

The callback can be a function, an object method, a static method or a closure. See php documentation to learn more about the callback pseudo-type.

Callback controllers return the rendered view output (see Views and templates).

They can take the pattern parameters as arguments

Callbacks called by routes can be written anywhere before the execution of the run() function. They can also be grouped in controller files stored in a controllers/ folder.

/                   # site root
 - index.php        # file with routes declarations and run()
 + controllers/
     - blog.php     # functions for blog: blog_index(), blog_show(),
                    #  blog_post()...
     - comments.php # comments_for_a_post(), comment_add()...

This folder location can be set with the controllers_dir option.

You can also define autoload_controller function to load controllers in your own way:

Url rewriting

Since version 0.4.1, Limonade supports url rewriting.

If you use Apache, with a .htaccess in your app folder

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  Options +Indexes
  RewriteEngine on

  # if your app is in a subfolder
  # RewriteBase /my_app/ 

  # test string is a valid files
  RewriteCond %{SCRIPT_FILENAME} !-f
  # test string is a valid directory
  RewriteCond %{SCRIPT_FILENAME} !-d

  RewriteRule ^(.*)$   index.php?uri=/$1    [NC,L,QSA]
  # with QSA flag (query string append),
  # forces the rewrite engine to append a query string part of the
  # substitution string to the existing string, instead of replacing it.
</IfModule>

If you use Nginx, add the following to your server declaration

server {
    location / {

        try_files $uri $uri/ @rewrite;
    }
    location @rewrite {
        rewrite ^/(.*)$ /index.php?u=$1&$args;
    }
}

then remember to set explicitly the option('base_uri') in your configure() function:

You can access your site with urls like http://your.new-website.com/my/limonade/path instead of http://your.new-website.com/?/my/limonade/path.

Views and templates

Template files are located by default in views/ folder. Views folder location can be set with the views_dir option.

To pass variables to templates, we use the function set ()

Variables may also be passed directly:

set_or_default function allows passing a variable, and if it's empty, a default value. It is really useful for the assignment of optional parameters extracted from the url using the params() function.

As you can notice, final output is returned by your controller. So remember to explicitly return your view in your controller with the return keyword! (This remark will be particularly helpful for rubyists ;-) )

Layouts

Templates may be rendered inside another template: a layout.

Layout may be set with the layout function:

or directly with the template rendering function

If layout value is null, rendering will be done without any layout.

Formatted strings and inline templates

Formatted string can be used like with sprintf:

It's also possible to provide a function name as a template. By this way, for example, we can produce a single file application.

HTML Templates

html function is used in the same way as render. A header specifies the proper HTTP Content-type (text/html) and encoding setting defined through options (utf8 by default).

Templates XML

xml function is used in the same way as render. A header specifies the proper HTTP Content-type (text/xml) and encoding setting defined through options (utf8 by default).

Templates CSS

css function is used in the same way as render. A header specifies the proper HTTP Content-type (text/css) and encoding setting defined through options (utf8 by default).

Templates JS

js function is used in the same way as render. A header specifies the proper HTTP Content-type (application/javascript) and encoding setting defined through options (utf8 by default).

Templates TXT

txt function is used in the same way as render. A header specifies the proper HTTP Content-type (text/plain) and encoding setting defined through options (utf8 by default).

Templates JSON

json is used the same way as json_encode function, and returns a string containing the JSON representation of a value. A header specifies the proper HTTP Content-type (application/x-javascript) and encoding setting defined through options (utf8 by default).

Serving files

The render_file function can render a file directly to the ouptut buffer.

A header specifies the proper HTTP Content-type depending on the file extension, and for text files, encoding setting defined through options (utf8 by default) .

Output is temporized so that it can easily handle large files.

Partials

The partial function is a shortcut to render with no layout. Useful for managing reusable blocks and keeping them in separate files.

This code

is the same as

Captures

The content_for function allows you to capture a block of text in a view. Then the captured block will be available for the layout. This is useful for management of layout regions like a sidebar or to set javascript or stylesheet files that are specific to a view.

For example with this layout:

And in your view:

Rendered result is:

The above example is detailed in this tutorial.

Use captures with partials, it will help you to organize your views and will keep you from having to copy/paste the same code many times.

Hooks and filters

Limonade allows the user to define some functions to enhance the Limonade behaviour with its own needs.

Some of those, like the before hook and the after filter are commonly used, and others are only for advanced usage that might require a good comprehension of Limonade internals.

Before

You can define a before function that will be executed before each request. This is very useful to define a default layout or for passing common variables to the templates.

The current matching route is also passed to the before function, so you can test it. It's an array as returned by the internal route_find function, with these values:

After

An after output filter is also available. It's executed after each request and can apply a transformation to the output (except for render_file outputs which are sent directly to the output buffer).

The current executed route is also available for after function.

Before render

You can define a before_render function that will filter your view before rendering it.

The first three parameters are the same as those passed to the render function:

Last parameter, $view_path is by default file_path(option('views_dir'), $content_or_func);

Autorender

You can define your own autorender function to make automatic rendering depending on current matching route. It will be executed if your controller returns a null output.

In this example, when url / is called, hello() is executed and then autorender() renders the matching hello.html.php view.

Before exit

If you define a before_exit, it is called at the begining of the stop/exit process (stop_and_exit function called automatically at Limonade application termination).

Before sending a header

You can define a before_sending_header function that will be called before Limonade emits a header() call. This way you can add additional headers:

Caution: Take care not to cause a loop by repeatedly calling send_header() from the before_sending_header() function!

Configuration

You can define a configure that will be executed when application is launched (at the begining of the run execution). You can define options inside it, a connection to a database ...

PHP files contained in the option('lib_dir') folder (lib/ by default) are loaded with require_once just after executing configure. So you can place in this folder all your PHP libraries and functions so that they will be loaded and available at application launch.

Options

The option function allows you to define and access the options of the application.

If the name of option is not specified, it returns an array of all the options set.

You can use it to manage Limonade options and your own custom options in your application.

Default Limonade options have the following values:

Sessions

Session starts automatically by default. Then you can access session variables like you used to do, with $_SESSION array.

You can disable sessions with the session option.

see snippet example

Flash

Flash is a special use of sessions. A flash value will be available only on next request and will be deleted after. It's very useful to raise errors on a form or to notice a successful action.

see snippet example

Helpers

See sources or api for more about all available helpers.

url_for

You can use the url_for function for rendering limonade urls. They will be well formed from whatever folder in the document root your application is installed on your web server.

If you want to use url rewriting, you need to explicitly set the base_uri option ( default is /your_file_path/?)

Halting and error handling

Halt

You can stop immediately the execution of the application with the halt function. Errors will be handled by default Limonade error handlers or those you have defined.

Not Found

By default, displays the not_found error output function and sends a 404 NOT FOUND HTTP header.

To define a new view for this error, you can simply declare a not_found function.

Server Error

By default, displays the server_error error output function and sends a 500 INTERNAL SERVER ERROR HTTP header.

PHP errors are also caught and sent to this error handler output.

To define a new view for this error, you can simply declare a server_error function.

Error layout

Allows you to define and access a layout dedicated to errors.

Error handling

In addition to the common NOT_FOUND and SERVER_ERROR error displays, Limonade can redirect precise errors to your own functions.

E_LIM_HTTP means all HTTP errors

E_LIM_PHP means all PHP errors (sent by PHP or raised by the user through trigger_error function).

Other useful functions

Limonade also provides a useful set of functions that can help you managing files, HTTP… For more about those utilities, see the source code at section 7. UTILS.

Testing

[TODO]

More


All versions of limo 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 martinjur/limo contains the following files

Loading the files please wait ....