Skip to content

Commit

Permalink
implemented autoloading
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomiwa-Ot committed Jan 21, 2024
1 parent 595eada commit 097585b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 7 deletions.
5 changes: 2 additions & 3 deletions Controller/BaseController.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php

namespace Grep\Controller;

/**
* Base View Controller
*/

require_once __DIR__ . '/../Library/Response.php';

use Grep\Library\Response;

class BaseController
{
Expand Down
4 changes: 3 additions & 1 deletion Controller/Index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

require_once __DIR__ . '/BaseController.php';
namespace Grep\Controller;

use function Grep\Library\render;

class Index extends BaseController
{
Expand Down
2 changes: 0 additions & 2 deletions Library/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
* @Wiki : https://github.com/Tomiwa-Ot/php-router/wiki
*/

require_once __DIR__ . '/Config.php';


class Router
{
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ class User extends BaseController
Via Git
```bash
git clone https://github.com/Tomiwa-Ot/php-router.git
cd php-router
composer install
```
Via Composer
```bash
composer create-project grephq/php-router
cd php-router
composer install
```

## Docs
Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"autoload": {
"psr-4": {
"Grep\\": "."
}
},
"name": "grephq/php-router",
"description": "Dynamic routing framework in php",
"type": "project",
Expand Down
18 changes: 18 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion routes.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

require_once __DIR__ . '/Library/Router.php';
require_once __DIR__ . '/vendor/autoload.php';

use Grep\Library\Config;
use Grep\Library\Router;

foreach (glob(__DIR__ . '/Controller/*.php') as $file) {
Expand Down

0 comments on commit 097585b

Please sign in to comment.