Web application framework for PHP 5.5+

Installs: 239

Dependents: 1

Stars: 5

Watchers: 4

Open Issues: 7

Language: PHP

0.4.1 2015-06-10 09:42 UTC

README

Packagist Travis Coverage Status License

Coast is a web application framework for PHP 5.5+. The goal of Coast is to provide a simple, lightweight and flexible framework for building high-performance, modern web apps. Some parts of the API were inspired by the Connect and Express node.js frameworks, others are my own (possibly ridiculous) ideas.

  • Easy handling of request and response data
  • View component for view, partial and layout rendering
  • Router component for advanced path routing
  • Controller component for advanced request handling
  • URL component for easy URL generation (static files, routes, query strings etc.)
  • Utility classes for working with config files, URLs, Atom feeds, XML sitemaps and the file system, plus a basic HTTP client library

All feedback, suggestions, bug reports and contributions are very welcome. Please feel free to get in touch by email (jacksleight at gmail dot com) or @jacksleight on Twitter.

The documentation and tests are still a work in progress (sorry). Until there's a stable release the API may change.

Installation

The easiest way to install Coast is through Composer, by creating a file called composer.json containing:

{
    "require": {
        "jacksleight/coast": "dev-master"
    }
}

And then running:

composer.phar install

Hello World

Create a new file called app.php containing:

<?php
use Coast\App,
    Coast\Request, 
    Coast\Response;

require __DIR__ . '/vendor/autoload.php';

$app = new App(__DIR__);
$app->executable(function(Request $req, Response $res) {
    return $res->text('Hello World');
});

$app->execute();

Then run:

php -S localhost:8000 app.php

And load it up in the browser at: http://localhost:8000/.

What's happening here?

  1. Include the Composer autoloader.
  2. Initialise a Coast\App object.
  3. Add middleware to handle the request.
  4. Call execute to run the application.

Documentation

Requirements

  • PHP 5.5+
  • mod_rewrite (if using Apache)

To Do

  • Examples (in progress)
  • API documentation (in progress)
  • Tests (in progress)

Roadmap

All of the items below are in progress, in fact they already exist as mostly working components of the library that became Coast, I've just not had a chance to update them yet.

  • Internationalisation component
  • Base entity class with validation
  • Image component with automatic image resizing
  • oEmbed component for including embedable content
  • HTML tidy component

Licence

The MIT License

Copyright (c) 2014 Jack Sleight http://jacksleight.com/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.