Skip to content

Commit

Permalink
Merge tag 'rename_namespace' into develop
Browse files Browse the repository at this point in the history
2.0.11

changelog:
	- rename namespace and change from liateam to mojtabarks
	- edit README.md file
  • Loading branch information
mojtaba rakhisi committed Jan 21, 2021
2 parents 1cdba6a + 06fea90 commit 3d4389a
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 120 deletions.
51 changes: 4 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,15 @@

a lightweight package for create and pass response for use in laravel || lumen

### Prerequisites

before start, you should have personal access token and SSH key.

* [how to create SSH-key](https://docs.gitlab.com/ee/ssh/README.html#generating-a-new-ssh-key-pair)
* [how to create personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#creating-a-personal-access-token)

next you should add your personal access token to composer

```
$ composer config \
--auth gitlab-token.gitlab.com "YOUR-TOKEN-HERE" \
--no-ansi \
--no-interaction
```

If you prefer to do this manually, create ~/.composer/auth.json, with the following content:
```
{
"gitlab-token": {
"gitlab.com": "YOUR-TOKEN-HERE"
}
}
```

### Installation

easily copy below code and paste in your `composer.json`

```
"repositories": {
"liateam/api-exceptions" : {
"type": "vcs",
"url": "[email protected]:php/packages/api-exceptions.git"
}
},
```

easily copy below code and paste in your `composer.json` -> `require` section

```
"liateam/api-exceptions": "^2.0"
```

run the command below in your project :

```
$ composer update
$ composer require mojtabarks/api-exceptions
```

### lumen specific installation
if your project is lumen so you should copy `Liateam/api-exceptions/src/config/exceptions` to your `config` directory !
if your project is lumen so you should copy `mojtabarks/api-exceptions/src/config/exceptions` to your `config` directory !
*NOTE* : If you don't have `config` directory so create it !

then add below code in your `bootstrap/app.php` :
Expand All @@ -63,15 +20,15 @@ then add below code in your `bootstrap/app.php` :

### laravel specific installation
```
$ php artisan vendor:publish --config="Liateam/api-exceptions/src/config/exceptions.php"
$ php artisan vendor:publish --provider="Mojtabarks/ApiExceptions/Providers/ApiExceptionServiceProvider"
```


## Usage

overwrite `render` method of `App\Exceptions\Handler` like this :
```
use Liateam\ApiExceptions\Handlers\ApiException;
use Mojtabarks\ApiExceptions\Handlers\ApiException;
public function render($request, Throwable $exception)
{
Expand Down
16 changes: 5 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "liateam/api-exceptions",
"name": "mojtabarks/api-exceptions",
"description": "Exception list using in api which help you to easy manage your api exceptions",
"type": "library",
"license": "MIT",
Expand All @@ -10,24 +10,18 @@
}
],
"require": {
"liateam/api-response": "2.*"
},
"repositories": {
"liateam/api-response" : {
"type": "vcs",
"url": "[email protected]:php/packages/api-response.git"
}
"mojtabarks/api-response": "2.*"
},
"autoload": {
"psr-4": {
"Liateam\\ApiExceptions\\": "src",
"Liateam\\ApiExceptions\\Tests\\" : "tests"
"Mojtabarks\\ApiExceptions\\": "src",
"Mojtabarks\\ApiExceptions\\Tests\\" : "tests"
}
},
"extra": {
"laravel": {
"providers": [
"Liateam\\ApiExceptions\\Providers\\ApiExceptionServiceProvider"
"Mojtabarks\\ApiExceptions\\Providers\\ApiExceptionServiceProvider"
]
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Contracts/ApiExceptionAbstract.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Liateam\ApiExceptions\Contracts;
namespace Mojtabarks\ApiExceptions\Contracts;

use Exception;
use \Throwable;
use Liateam\ApiResponse\Responses\FailureResponse;
use Liateam\ApiResponse\Contracts\ResponseContract;
use Mojtabarks\ApiResponse\Responses\FailureResponse;
use Mojtabarks\ApiResponse\Contracts\ResponseContract;

abstract class ApiExceptionAbstract extends Exception
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/CustomAuthenticationException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Liateam\ApiExceptions\Exceptions;
namespace Mojtabarks\ApiExceptions\Exceptions;

use Throwable;
use Illuminate\Http\Response;
use Liateam\ApiExceptions\Contracts\ApiExceptionAbstract;
use Mojtabarks\ApiExceptions\Contracts\ApiExceptionAbstract;

class CustomAuthenticationException extends ApiExceptionAbstract
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/CustomDefaultException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Liateam\ApiExceptions\Exceptions;
namespace Mojtabarks\ApiExceptions\Exceptions;

use Throwable;
use Illuminate\Http\Response;
use Liateam\ApiExceptions\Contracts\ApiExceptionAbstract;
use Mojtabarks\ApiExceptions\Contracts\ApiExceptionAbstract;

class CustomDefaultException extends ApiExceptionAbstract
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/CustomModelNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Liateam\ApiExceptions\Exceptions;
namespace Mojtabarks\ApiExceptions\Exceptions;

use Throwable;
use Illuminate\Http\Response;
use Liateam\ApiExceptions\Contracts\ApiExceptionAbstract;
use Mojtabarks\ApiExceptions\Contracts\ApiExceptionAbstract;

class CustomModelNotFoundException extends ApiExceptionAbstract
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/CustomNotFoundHttpException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Liateam\ApiExceptions\Exceptions;
namespace Mojtabarks\ApiExceptions\Exceptions;

use Throwable;
use Illuminate\Http\Response;
use Liateam\ApiExceptions\Contracts\ApiExceptionAbstract;
use Mojtabarks\ApiExceptions\Contracts\ApiExceptionAbstract;

class CustomNotFoundHttpException extends ApiExceptionAbstract
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/CustomRouteNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Liateam\ApiExceptions\Exceptions;
namespace Mojtabarks\ApiExceptions\Exceptions;

use Throwable;
use Illuminate\Http\Response;
use Liateam\ApiExceptions\Contracts\ApiExceptionAbstract;
use Mojtabarks\ApiExceptions\Contracts\ApiExceptionAbstract;

class CustomRouteNotFoundException extends ApiExceptionAbstract
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/CustomUnauthorizedException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Liateam\ApiExceptions\Exceptions;
namespace Mojtabarks\ApiExceptions\Exceptions;

use Throwable;
use Illuminate\Http\Response;
use Liateam\ApiExceptions\Contracts\ApiExceptionAbstract;
use Mojtabarks\ApiExceptions\Contracts\ApiExceptionAbstract;

class CustomUnauthorizedException extends ApiExceptionAbstract
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/CustomUnexpectedException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Liateam\ApiExceptions\Exceptions;
namespace Mojtabarks\ApiExceptions\Exceptions;

use Throwable;
use Illuminate\Http\Response;
use Liateam\ApiExceptions\Contracts\ApiExceptionAbstract;
use Mojtabarks\ApiExceptions\Contracts\ApiExceptionAbstract;

class CustomUnexpectedException extends ApiExceptionAbstract
{
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/CustomValidationException.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Liateam\ApiExceptions\Exceptions;
namespace Mojtabarks\ApiExceptions\Exceptions;

use Exception;
use Throwable;
use Illuminate\Http\Response;
use Liateam\ApiExceptions\Contracts\ApiExceptionAbstract;
use Mojtabarks\ApiExceptions\Contracts\ApiExceptionAbstract;

class CustomValidationException extends ApiExceptionAbstract
{
Expand Down
6 changes: 3 additions & 3 deletions src/Handlers/ApiException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Liateam\ApiExceptions\Handlers;
namespace Mojtabarks\ApiExceptions\Handlers;

use Throwable;
use Liateam\ApiResponse\Contracts\ResponseContract;
use Liateam\ApiExceptions\Exceptions\CustomDefaultException;
use Mojtabarks\ApiResponse\Contracts\ResponseContract;
use Mojtabarks\ApiExceptions\Exceptions\CustomDefaultException;

/**
* The classic CoR (Chain of Responsibility) pattern declares a single role for objects that make up a
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/ApiExceptionServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Liateam\ApiExceptions\Providers;
namespace Mojtabarks\ApiExceptions\Providers;

use Illuminate\Support\ServiceProvider;

Expand Down
12 changes: 6 additions & 6 deletions src/config/exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use \Illuminate\Auth\AuthenticationException;
use Illuminate\Validation\ValidationException;
use \Illuminate\Database\Eloquent\ModelNotFoundException;
use \Liateam\ApiExceptions\Exceptions\CustomDefaultException;
use \Liateam\ApiExceptions\Exceptions\CustomValidationException;
use \Liateam\ApiExceptions\Exceptions\CustomNotFoundHttpException;
use \Liateam\ApiExceptions\Exceptions\CustomUnauthorizedException;
use \Liateam\ApiExceptions\Exceptions\CustomModelNotFoundException;
use \Mojtabarks\ApiExceptions\Exceptions\CustomDefaultException;
use \Mojtabarks\ApiExceptions\Exceptions\CustomValidationException;
use \Mojtabarks\ApiExceptions\Exceptions\CustomNotFoundHttpException;
use \Mojtabarks\ApiExceptions\Exceptions\CustomUnauthorizedException;
use \Mojtabarks\ApiExceptions\Exceptions\CustomModelNotFoundException;
use \Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use \Liateam\ApiExceptions\Exceptions\CustomAuthenticationException;
use \Mojtabarks\ApiExceptions\Exceptions\CustomAuthenticationException;
use \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;

return [
Expand Down
4 changes: 2 additions & 2 deletions tests/BaseTestCase.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace Liateam\ApiExceptions\Tests;
namespace Mojtabarks\ApiExceptions\Tests;

use Faker\Factory;
use ReflectionClass;
use Illuminate\Http\Request;
use Laravel\Lumen\Testing\TestCase;
use Illuminate\Container\Container;
use Laravel\Lumen\Exceptions\Handler;
use Liateam\ApiResponse\Responses\FailureResponse;
use Mojtabarks\ApiResponse\Responses\FailureResponse;

abstract class BaseTestCase extends TestCase
{
Expand Down
18 changes: 9 additions & 9 deletions tests/Feature/HandlerTest.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

namespace Liateam\ApiExceptions\Tests\Feature;
namespace Mojtabarks\ApiExceptions\Tests\Feature;

use Mockery\Exception;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Liateam\ApiExceptions\Tests\BaseTestCase;
use Liateam\ApiExceptions\Handlers\ApiException;
use Liateam\ApiExceptions\Exceptions\CustomUnexpectedException;
use Liateam\ApiExceptions\Exceptions\CustomNotFoundHttpException;
use Liateam\ApiExceptions\Exceptions\CustomUnauthorizedException;
use Liateam\ApiExceptions\Exceptions\CustomModelNotFoundException;
use Liateam\ApiExceptions\Exceptions\CustomRouteNotFoundException;
use Liateam\ApiExceptions\Exceptions\CustomAuthenticationException;
use Mojtabarks\ApiExceptions\Tests\BaseTestCase;
use Mojtabarks\ApiExceptions\Handlers\ApiException;
use Mojtabarks\ApiExceptions\Exceptions\CustomUnexpectedException;
use Mojtabarks\ApiExceptions\Exceptions\CustomNotFoundHttpException;
use Mojtabarks\ApiExceptions\Exceptions\CustomUnauthorizedException;
use Mojtabarks\ApiExceptions\Exceptions\CustomModelNotFoundException;
use Mojtabarks\ApiExceptions\Exceptions\CustomRouteNotFoundException;
use Mojtabarks\ApiExceptions\Exceptions\CustomAuthenticationException;

class HandlerTest extends BaseTestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/CustomAuthenticationExceptionTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Liateam\ApiExceptions\Tests\Unit;
namespace Mojtabarks\ApiExceptions\Tests\Unit;

use Mockery\Exception;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Liateam\ApiExceptions\Tests\BaseTestCase;
use Liateam\ApiExceptions\Exceptions\CustomAuthenticationException;
use Mojtabarks\ApiExceptions\Tests\BaseTestCase;
use Mojtabarks\ApiExceptions\Exceptions\CustomAuthenticationException;

class CustomAuthenticationExceptionTest extends BaseTestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/CustomDefaultExceptionTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Liateam\ApiExceptions\Tests\Unit;
namespace Mojtabarks\ApiExceptions\Tests\Unit;

use Mockery\Exception;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Liateam\ApiExceptions\Tests\BaseTestCase;
use Liateam\ApiExceptions\Exceptions\CustomDefaultException;
use Mojtabarks\ApiExceptions\Tests\BaseTestCase;
use Mojtabarks\ApiExceptions\Exceptions\CustomDefaultException;

class CustomDefaultExceptionTest extends BaseTestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/CustomModelNotFoundExceptionTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Liateam\ApiExceptions\Tests\Unit;
namespace Mojtabarks\ApiExceptions\Tests\Unit;

use Mockery\Exception;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Liateam\ApiExceptions\Tests\BaseTestCase;
use Liateam\ApiExceptions\Exceptions\CustomModelNotFoundException;
use Mojtabarks\ApiExceptions\Tests\BaseTestCase;
use Mojtabarks\ApiExceptions\Exceptions\CustomModelNotFoundException;

class CustomModelNotFoundExceptionTest extends BaseTestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/CustomNotFoundHttpExceptionTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Liateam\ApiExceptions\Tests\Unit;
namespace Mojtabarks\ApiExceptions\Tests\Unit;

use Mockery\Exception;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Liateam\ApiExceptions\Tests\BaseTestCase;
use Liateam\ApiExceptions\Exceptions\CustomNotFoundHttpException;
use Mojtabarks\ApiExceptions\Tests\BaseTestCase;
use Mojtabarks\ApiExceptions\Exceptions\CustomNotFoundHttpException;

class CustomNotFoundHttpExceptionTest extends BaseTestCase
{
Expand Down
Loading

0 comments on commit 3d4389a

Please sign in to comment.