Download the PHP package inphinit/teeny without Composer

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

Teeny route system for PHP

Teeny is a micro-route system that is really micro, supports PHP 5.3 to PHP 8, is extremely simple and ready to use.

Install using Composer

To create a new project, run:

Replace <project name> by your project name, example:

Download without Composer

If you are not using Composer, you can download Teeny directly from https://github.com/inphinit/teeny/releases

Apache (.htaccess)

The .htaccess will only need some adjustment if you are using it in a subfolder, you will need to change all ErrorDocument. More details at https://httpd.apache.org/docs/2.4/custom-error.html.

If the address is something like https://<domain>/, then do:

If the address is something like https://<domain>/foo/, then do:

If the address is something like https://<domain>/foo/bar/, then do:

NGINX

For NGINX you can use try_files, example:

Note: For FPM use fastcgi_pass unix:/var/run/php/php<version>-fpm.sock (replace <version> by PHP version in your server)

Built-in web server

You can use built-in server to facilitate the development, Teeny provides the relative static files, which will facilitate the use, example of use (navigate to project folder using cd command):

You can edit the server.bat (Windows) or server (Linux or macOS) files to make it easier to start the project with a simple command

Windows (server.bat file)

Configure the server.bat variables according to your environment:

Once configured, you can navigate to the project folder and run the command that will start the built-in web server, example:

Linux and macOS (server file)

Configure the ./server variables according to your environment:

Once configured, you can navigate to the project folder and run the command that will start built-in server, example:

API

Methods from Teeny class

Method Description
Teeny::path(): string Get current path from URL (ignores subfolders if it is located in a subfolder on your webserver)
Teeny::status([int $code]): int Get or set HTTP status code
Teeny::action($methods, string $path, mixed $callback): void Register a callback or script for a route
Teeny::setPattern(string $pattern, string $regex): void Add or replace a pattern for custom routes, like /foo/<variable1:pattern>
Teeny::handlerCodes(array $codes, mixed $callback): void Handler HTTP status code
Teeny::exec(): bool Execute application

Add and remove routes

To create a new route in index.php put like this:

You can use return:

To remove a route use null value, like this:

Route include file

To include a file uses like this:

If is foo/bar/test.php not found in project will display the following error:

HTTP status

To retrieve HTTP status from SAPI (Apache, Ngnix, IIS) or previously defined in the script itself use it like this:

To retrieve into a route use it like this:

To set a new HTTP status use it like this (eg.: emit 404 Not Found):

To set into route use it like this (a example with condition/if):

Named params in route

You can use params like this:

If you access a URL like this http://mywebsite/user/mary returns:

Another example:

If you access a URL like this http://mywebsite/article/mary-1000 returns:

Supported types for named parameters in routes

An example, only numeric id are valid:

Type Example Description
alnum $app->action('GET', '/baz/<video:alnum>', ...); Only accepts parameters with alpha-numeric format and $params returns array( video => ...)
alpha $app->action('GET', '/foo/bar/<name:alpha>', ...); Only accepts parameters with alpha format and $params returns array( name => ...)
decimal $app->action('GET', '/baz/<price:decimal>', ...); Only accepts parameters with decimal format and $params returns array( price => ...)
num $app->action('GET', '/foo/<id:num>', ...); Only accepts parameters with integer format and $params returns array( id => ...)
nospace $app->action('GET', '/foo/<nospace:nospace>', ...); Accepts any characters except spaces, like white-spaces (%20), tabs (%0A) and others (see about \S in regex)
uuid $app->action('GET', '/bar/<barcode:uuid>', ...); Only accepts parameters with UUID format and $params returns array( barcode => ...)
version $app->action('GET', '/baz/<api:version>', ...); Only accepts parameters with semversion (v2) format and $params returns array( api => ...)

For add new patterns use it like this Teeny::setPattern(), examples:

And to access this route exemple use http://mysite/test/A00001 or http://mysite/test/C02, start with upper-case letter and after with an integer number

Dealing with large files

To work with large files you can choose to use the following server modules:

Module Server Documentation
X-Sendfile Apache https://tn123.org/mod_xsendfile/
X-Accel-Redirect NGINX https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/
X-LIGHTTPD-send-file and X-Sendfile2 Lighttpd https://redmine.lighttpd.net/projects/1/wiki/X-LIGHTTPD-send-file

A simple example:

Serving public files (and scripts)

To serve public files (or scripts) you must add them to the public folder. The /public/* prefix is removed from the final URL, for example, if there is a file like public/foobar.html, then the user will simply access the address https://<domain>/foobar.html.

Subfolders will also work, if it has a file like public/foo/bar/baz/video.webm then the user should go to https://<domain>/foo/bar/baz/video.webm.

You can add PHP scripts, and they will be executed normally, if you have a script like public/sample/helloworld.php, just access https://<domain>/sample/helloworld.php

If you want to make a blog available, such as Wordpress, you must also place it inside the folder, an example of structure:

You can then access the blog at https://<domain>/blog/. Other samples:


If you need more features you can experience the Inphinit PHP framework: https://inphinit.github.io/


All versions of teeny with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 inphinit/teeny contains the following files

Loading the files please wait ...