2017 © Pedro Peláez
 

library wallaby

A simple lightweight framework for building small apps in PHP

image

ursuleacv/wallaby

A simple lightweight framework for building small apps in PHP

  • Thursday, May 17, 2018
  • by ursuleacv
  • Repository
  • 2 Watchers
  • 1 Stars
  • 71 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 4 % Grown

The README.md

wallaby

A simple lightweight MVC framework for building small apps in PHP., (*1)

Built in support for layouts, themes, routing., (*2)

Usage

Create composer.json file, (*3)

{
    "require": {
        "php": ">=5.6.0",
        "ext-json": "*",
        "ext-pdo": "*",
        "ursuleacv/wallaby": "dev-master"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        }
    }
}

Run composer install, (*4)

Create a project with the following structure, (*5)

app
    Controllers
        BaseController.php
        HomeController.php
    Models
        User.php
config
    router.php
    app.php
public
    themes
        default
            views
                home
                    index.php
                    login.php
                layouts
                    main.php
        beta
            views
    index.php
server.php

Example BaseController.php, (*6)

<?php

namespace App\Controllers;

use Wallaby\Base\Controller;

class BaseController extends Controller
{
    /**
     *
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();

        $this->theme = 'default';
        $this->layout = 'layouts/main';
    }
}

Example HomeController.php, (*7)

<?php

namespace App\Controllers;

class HomeController extends BaseController
{
    /**
     *
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();

        $this->theme = 'default'; // You can override the theme
        $this->layout = 'layouts/main';
    }

    /**
     * @return void
     */
    public function autoLogin()
    {
        //
    }
}

public/index.php, (*8)

<?php
date_default_timezone_set('UTC');
require __DIR__.'/../vendor/autoload.php';

require __DIR__.'/../server.php';

server.php, (*9)

<?php

use Wallaby\Router;

error_reporting(-1);

defined('ROOT') or define('ROOT', __DIR__);
defined('PUBLIC_DIR') or define('PUBLIC_DIR', 'public');

$config = require_once __DIR__ . '/config/app.php';

$debug = isset($config['debug']) ? $config['debug'] : false;

defined('APP_DEBUG') or define('APP_DEBUG', $debug);

$url = trim($_SERVER['REQUEST_URI'], '/');

$configRouter = require_once ROOT . '/config/router.php';

$router = new Router($configRouter);

$router->start($url);

config/app.php, (*10)

<?php
    return [
        'appName' => 'My App Name',
        'appBaseUrl' => 'http://localhost', // no trailing slash
        'theme' => 'default',
        'version' => 'v1.0.0',
    ];

config/router.php, (*11)

this will automatically match all routes with the following format, (*12)

controller/action/param1/param2, (*13)

controller/action/?param1=value1&param2=value2, (*14)

Ex:, (*15)

http:localhost/site/register, (*16)

http:localhost/site/contact, (*17)

http:localhost/product/edit/123, (*18)

<?php
    return [
        'baseAction' => 'index',
        'baseController' => 'home',
        'errorHandler' => 'home/error',
        'routes' => '^(?<controller>[a-z-A-Z]+)?/?(?<action>[a-z-A-Z]+)?/?(?<parameter>.*[a-z0-9/-])?/?(?<query>\?.*)?$',
    ];

The Versions

17/05 2018

dev-master

9999999-dev

A simple lightweight framework for building small apps in PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

micro php mvc simple wallaby

17/05 2018

v1.0.4

1.0.4.0

A simple lightweight framework for building small apps in PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

micro php mvc simple wallaby

16/05 2018

v1.0.3

1.0.3.0

A simple lightweight framework for building small apps in PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

micro php mvc simple wallaby

27/03 2018

v1.0.2

1.0.2.0

A simple lightweight framework for building small apps in PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

micro php mvc simple wallaby

14/03 2018

v1.0.1

1.0.1.0

A simple lightweight framework for building small apps in PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

micro php mvc simple wallaby

03/01 2018

v1.0

1.0.0.0

A simple lightweight framework for building small apps in PHP

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

micro php mvc simple wallaby