-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e77ab3c
Showing
7 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Lumen Custome Routes | ||
|
||
![lumen-custome-routes](assets/background.png) | ||
|
||
A Simple Lumen package to help you customize your routes apiResources. | ||
|
||
Specialize for whom using lumen, if you don't you better do now ^^, | ||
Lumen is stunningly micro-framework Faster 4x than laravel. | ||
|
||
# Installation | ||
<pre>composer require lararoute/lumen-custom-routes</pre> | ||
|
||
# Usage | ||
Add this line in top of routes/web.php | ||
<pre>use Lararoutes\Lumen\CustomRoutes;</pre> | ||
<pre>$app = new CustomRoutes($router);</pre> | ||
|
||
That's it. done | ||
|
||
# Example | ||
Instead of doing this shit | ||
<pre> | ||
$router->get('posts', 'PostController@index'); | ||
$router->post('posts', 'PostController@store'); | ||
$router->get('posts/{id}', 'PostController@show'); | ||
$router->put('posts/{id}', 'PostController@update'); | ||
$router->delete('posts/{id}', 'PostController@destroy'); | ||
</pre> | ||
|
||
We Can simple do this now | ||
<pre>$app->apiResoruce('posts', 'PostController');</pre> | ||
|
||
However, you can also custom your routes as much as u want in Lararoute\Lumen\CustomRoutes.php | ||
<pre> | ||
function apiResoruce($uri, $controller) | ||
{ | ||
$this->app->get($uri, $controller.'@index'); | ||
$this->app->post($uri, $controller.'@store'); | ||
$this->app->get($uri.'/{id}', $controller.'@show'); | ||
$this->app->put($uri.'/{id}', $controller.'@update'); | ||
$this->app->delete($uri.'/{id}', $controller.'@destroy'); | ||
|
||
// feel free to add more | ||
|
||
} | ||
</pre> | ||
|
||
# Credits | ||
|
||
<ul> | ||
<li><a href="https://github.com/Mahmoud-Italy">Mahmoud Italy</a></li> | ||
<li><a href="https://github.com/Mahmoud-Italy/Lararoutes-lumen-custom-routes/graphs/contributors">All Contributors</a></li> | ||
</ul> | ||
|
||
# License | ||
The MIT License (MIT). Please see License File for more information. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "lararoutes/lumen-custom-routes", | ||
"description": "A Simple Lumen package to help you customize your routes apiResources.", | ||
"keywords": [ | ||
"lararoute", | ||
"routes", | ||
"resources", | ||
"apiResources" | ||
"lumen", | ||
"larave", | ||
], | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Mahmoud.Ahmed", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"require": { | ||
"php": "^7.2" | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Lararoutes\\Lumen\\CustomRoutes\\CustomRoutesServiceProvider" | ||
] | ||
} | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Lararoutes\\Lumen\\CustomRoutes\\": "src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false"> | ||
<filter> | ||
<whitelist> | ||
<directory>./src/</directory> | ||
</whitelist> | ||
</filter> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="APP_ENV" value="testing"/> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Lararoutes\Lumen\CustomRoutes; | ||
|
||
class CustomRoutes | ||
{ | ||
protected $app; | ||
|
||
public function __construct($router='') | ||
{ | ||
$this->app = $router; | ||
} | ||
|
||
function apiResoruce($uri, $controller) | ||
{ | ||
$this->app->get($uri, $controller.'@index'); | ||
$this->app->post($uri, $controller.'@store'); | ||
$this->app->get($uri.'/{id}', $controller.'@show'); | ||
$this->app->put($uri.'/{id}', $controller.'@update'); | ||
$this->app->delete($uri.'/{id}', $controller.'@destroy'); | ||
|
||
// feel free to add more | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Lararoutes\Lumen\CustomRoutes; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class CustomRoutesServiceProvider extends ServiceProvider | ||
{ | ||
|
||
/** | ||
* Bootstrap the application services. | ||
*/ | ||
public function boot() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Register the application services. | ||
*/ | ||
public function register() | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Lararoute\Lumen\CustomeRoutes\Tests; | ||
|
||
use PHPUnit\Framework\TestCase as BaseTestCase; | ||
|
||
class TestCase extends BaseTestCase | ||
{ | ||
/** @test */ | ||
public function test() | ||
{ | ||
$this->assertTrue(true); | ||
} | ||
} |