PHP code example of propaysystems / laravel-base-repositories
1. Go to this page and download the library: Download propaysystems/laravel-base-repositories library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
propaysystems / laravel-base-repositories example snippets
class AddressRepository extends BaseRepository implements AddressRepositoryInterface
interface AddressRepositoryInterface extends BaseRepositoryInterface
bash
php artisan vendor:publish --tag="laravel-base-repositories-config"
bash [php]
BASE_SERVICE_PATH="App\MyServiceFolder"
bash [php]
APPEND_SERVICE_NAME="Service"
bash [php]
BASE_REPOSITORY_PATH="App\MyRepositoryFolder"
bash [php]
APPEND_REPOSITORY_NAME="Repository"
bash [php]
php artisan base:create Users/User --service
or
php artisan base:create Users/User -s
bash [php]
PHP 8.1 & above using constructor promotion
public function __construct(
protected UserRepositoryInterface $userRepository,
)
{}
or
PHP 8.0 & below
protected UserRepositoryInterface $userRepository;
public function __construct(
UserRepositoryInterface $userRepository,
)
{
$this->userRepository = $userRepository;
}
bash [php]
...
/*
* Package Service Providers...
*/
App\Providers\RepositoryServiceProvider::class,
...