Skip to content

Commit

Permalink
change default namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
nda666 committed Jul 29, 2022
1 parent e9d47c3 commit 6498293
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
on: [push, pull_request]
name: PhpStan

jobs:
test:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: [8, 7.4, 7.3, 7.2]
phpunit-versions: [latest]

steps:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug
- uses: actions/checkout@v2

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist

- name: Run static analysis (phpstan)
run: composer run phpstan
5 changes: 1 addition & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on: [push, pull_request]
name: tests
name: Testing

jobs:
test:
Expand Down Expand Up @@ -34,8 +34,5 @@ jobs:
- name: Run lint
run: composer run lint

- name: Run static analysis (phpstan)
run: composer run phpstan

- name: Run test
run: composer run test
14 changes: 8 additions & 6 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
# Laravel Repository Patterent

It's a simple repository file generator.

## Laravel without auto-discovery:

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

```shell
LaravelRepositoryPattern\Providers\RepositoryPatternProvider::class
```

to publish the config file:

```shell
php artisan vendor:publish --provider="LaravelRepositoryPattern\Providers\RepositoryPatternProvider"
```

## How To:
```shell

```shell
php artisan make:repository User
```

Will generate UserRepository.php and UserInterface.php file

## Example

Example using generated repo in controller

```php
<?php

namespace App\Http\Controllers;

use App\Interfaces\UserInterface;
use App\Repositories\UserRepository;

class HomeController extends Controller
{
protected UserRepository $user;

public function __construct(UserInterface $user)
public function __construct(UserRepository $user)
{
$this->user = $user;
}
Expand All @@ -45,6 +50,3 @@ class HomeController extends Controller
}
}
```

## Todo List:
- [ ] Creating test
3 changes: 1 addition & 2 deletions publishable/config/laravel-repository-pattern.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

return [
"interface_namespace" => "App\\Interfaces",

"interface_namespace" => "App\\Contracts",
"repository_namespace" => "App\\Repositories",
];
1 change: 0 additions & 1 deletion src/Stubs/make-interface.stub
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ namespace DummyNamespace;

interface DummyClass
{
public function getAll();
}

0 comments on commit 6498293

Please sign in to comment.