Download the PHP package aloefflerj/yet-another-controller without Composer

On this page you can find all versions of the php package aloefflerj/yet-another-controller. 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 yet-another-controller

Yet Another PHP Controller

Here is how it works (for now):

Installation

composer require aloefflerj/yet-another-controller

Quick Usage

  1. Simple Setup

    index.php

  2. Adding a simple GET route

    index.php

  3. Dispatching routes

    index.php

  4. Start your webserver

    A simple way to do it would be with the PHP built-in web server:

    Run php -S localhost:8000 -t path/to/your/index

  5. Go to your domain home page http://localhost:8000/

    outputs: 'Welcome home'


Request and Response

The $request and $response arguments on closure output are PSR-7 implementations.

The return of the closure must be a StreamInterface implementation for the output to work.

Since the return of $response->getBody() is a StreamInterface implementation the code above will print:

outputs: 'Welcome home'

Alternatively you could simply do echo $response->getBody();


Uri Params Usage

You can pass uri params wiht the syntax /route/{param}.

For the param to be accessed, you need a third param on get method: \stdClass $args.

To access it inside the closure output, you must use $args->param. See the example below:

url: localhost:8000/mascots/elephant

outputs: 'PHP elephant mascot is awesome'


Getting the Request Body

To get the body from a request you can access it from the $request implementation with $request->getBody() (a StreamInterface implementation).

The example below will print the request body.

If I request a POST with the following body:

The return should be the same:


Obs: although you could try this controller out if you want, this project is just an excuse for me to study and have fun :v

All versions of yet-another-controller with dependencies

PHP Build Version
Package Version
Requires psr/http-message Version ^1.0
guzzlehttp/guzzle Version ^7.5
vishnubob/wait-for-it Version dev-master
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 aloefflerj/yet-another-controller contains the following files

Loading the files please wait ....