Skip to content

Commit

Permalink
first init
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmoud-Italy committed Aug 1, 2020
0 parents commit e77ab3c
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 0 deletions.
56 changes: 56 additions & 0 deletions README.md
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.
Binary file added assets/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions composer.json
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/"
}
}
}
24 changes: 24 additions & 0 deletions phpunit.xml
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>
24 changes: 24 additions & 0 deletions src/CustomeRoutes.php
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
}
}
25 changes: 25 additions & 0 deletions src/CustomeRoutesServiceProvider.php
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()
{
//
}
}
14 changes: 14 additions & 0 deletions test/TestCase.php
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);
}
}

0 comments on commit e77ab3c

Please sign in to comment.