2017 © Pedro Peláez
 

library mvc

Another MVC framework

image

koine/mvc

Another MVC framework

  • Friday, August 28, 2015
  • by mjacobus
  • Repository
  • 1 Watchers
  • 1 Stars
  • 78 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Koine Mvc

Another very simple MVC framework., (*1)

Code information:, (*2)

Build Status Coverage Status Code Climate Scrutinizer Code Quality, (*3)

Package information:, (*4)

Latest Stable Version Total Downloads Latest Unstable Version License Dependency Status, (*5)

Skeleton app

For a ready to use app clone the skeleton app or follow its composer instalation guide., (*6)

Usage

 $env,
    'cookies'     => $cookies,
    'session'     => $session,
    'params'      => $params,
));

// set view
$view = new \Koine\Mvc\View();
$view->getConfig()->addPath(__DIR__ . '/views');

// set front controller
$frontController = new \Koine\Mvc\FrontController();
$frontController->setRequest($request)
    ->setController('MyApp\HelloWordController')
    ->setAction('sayHello')
    ->setView($view);

$response = $frontController->execute();
$response->send();

exit();
```

The controller:

```php
getRequest()->getSession();

        if (!$session['user_id']) {
            throw new \MyApp\AccessDeniedException("User is not logged");
        }
    }

    public function sayHello()
    {
        $this->view->setLayout('layouts/application');

        $this->render->('hello_world/say_hello', array(
            'message' => 'Hello World!'
        ));

        // or

        $this->getResponse()->setBody('Hello World!');
    }

    public function redirectToHome()
    {
        $this->getResponse()->redirectTo('/');
    }
}
```

The layout:

```phtml

Some Layout!

= $this->render($this->view, $this->localVariables) ?>

Note that in order to render the view in the layout you MUST pass the $this->view and the $this->localVariables variable in order to make them available in the view, (*7)

The view;, (*8)

<!-- hello_word.phtml -->
<p><?= $message ?></p>

Testing


namespace MyAppTests; use Koine\Test\Mvc\ControllerTestCase; class HelloWordControllerTest extends ControllerTestCase { public function setUp() { $this->setUpController('MyApp\\HelloWordController'); } public function testSayHelloWhenUserIsLoggedIn() { $session = array('user_id'); $params = array(); $this->getRequest('sayHello', $params, $session); $this->assertResponseCode(200); } /** * @expectedException MyApp\AccessDenied */ public function testThrowsExceptionWhenUserIsNotLoggedIn() { $this->getRequest('sayHello', $params, $session); } protected function testRedirectsToHome() { $this->getRequest('rediresctsToHome'); $this->assertResponseIsRedirect(); $this->assertResponseRedirectsTo('/'); // or $this->assertTrue($this->getResponse()->isRedirect()); $headers = $this->getResponse()->getHeaders(); $this->assertEquals('Location: /', $headers['Location']); } }

Installing

Via Composer

Append the lib to your requirements key in your composer.json., (*9)

{
    // composer.json
    // [..]
    require: {
        // append this line to your requirements
        "koine/mvc": "~0.9.7"
    }
}

Alternative install

Issues/Features proposals

Here is the issue tracker., (*10)

Contributing

Only TDD code will be accepted. Please follow the PSR-2 code standard., (*11)

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

How to run the tests:

phpunit --configuration tests/phpunit.xml

To check the code standard run:

phpcs --standard=PSR2 lib
phpcs --standard=PSR2 tests

Lincense

MIT, (*12)

Authors

The Versions

28/08 2015

dev-master

9999999-dev

Another MVC framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

16/08 2015

1.0

1.0.0.0

Another MVC framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

24/09 2014

0.9.8

0.9.8.0

Another MVC framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

19/09 2014

0.9.7

0.9.7.0

Another MVC framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

19/09 2014

0.9.6

0.9.6.0

Another MVC framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

09/09 2014

0.9.4

0.9.4.0

Another MVC framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

05/09 2014

0.9.3

0.9.3.0

Another MVC framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

05/09 2014

0.9.2

0.9.2.0

Another MVC framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

04/09 2014

0.9.1

0.9.1.0

Another MVC framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus

03/09 2014

0.9.0

0.9.0.0

Another MVC framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcelo Jacobus