Quick Start

Installation is done via composer

composer create-project -n bear/skeleton MyVendor.MyProject

Next, let’s create a page resource. A page resource is a class which corresponds to a web page. Create your own basic page resource in MyVendor.MyPackage/src/Resource/Page/Hello.php

<?php
namespace MyVendor\MyProject\Resource\Page;

use BEAR\Resource\ResourceObject;

class Hello extends ResourceObject
{
    public function onGet($name = 'BEAR.Sunday')
    {
        $this['greeting'] = 'Hello ' . $name;

        return $this;
    }
}

In the above example, when the page is requested using a GET method, Hello and $_GET['name'] strings are joined, and assigned to a variable greeting. The BEAR.Sunday application that you have created will work on a web server, but also in the console.

php bootstrap/web.php get /hello
php bootstrap/web.php get '/hello?name=World'

200 OK
Content-Type: application/hal+json

{
    "greeting": "Hello World",
    "_links": {
        "self": {
            "href": "/hello?name=World"
        }
    }
}

Let us fire up the php server and access our page at http://127.0.0.1:8080/hello.

php -S 127.0.0.1:8080 var/www/index.php