1. Go to this page and download the library: Download billyranario/prostarterkit 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/ */
billyranario / prostarterkit example snippets
use Billyranario\ProstarterKit\App\Http\Requests\BaseRequest;
use Billyranario\ProstarterKit\App\Dtos\BaseDto;
// In your controller
public function index(BaseRequest $request) {
$baseDto = new BaseDto();
$baseDto->setPerPage($request->getInputAsInt('perPage'));
$baseDto->setOrderBy($request->getInputAsString('orderBy'));
// Your business logic here
}
use Billyranario\ProstarterKit\App\Core\ResponseHelper;
// Sending JSON data with status code 200
ResponseHelper::json(['message' => 'Hello World']);
// Sending a 200 OK status code
ResponseHelper::ok();
// Sending an empty JSON object with status code 200
ResponseHelper::empty();
use Billyranario\ProstarterKit\App\Core\ServiceResponse;
// Create a success response
$response = ServiceResponse::success('Operation successful', ['data' => 'some_data']);
use Billyranario\ProstarterKit\App\Dtos\BaseDto;
$baseDto = new BaseDto();
$baseDto->setPerPage(20);
$baseDto->setOrderBy('created_at');
use Billyranario\ProstarterKit\App\Repositories\Contracts\UserRepositoryInterface;
class UserRepository implements UserRepositoryInterface
{
// implementation here
}
use Billyranario\ProstarterKit\App\Core\ServiceResponse;
// Create a success response
$response = ServiceResponse::success('Operation successful', ['data' => 'some_data']);
use Billyranario\ProstarterKit\App\Http\Requests\BaseRequest;
use Billyranario\ProstarterKit\App\Dtos\BaseDto;
class MyRequest extends BaseRequest
{
public function rules()
{
return [
// validation rules
];
}
public function toDto(): BaseDto
{
$baseDto = new BaseDto();
$baseDto->setPerPage($this->getInputAsInt('perPage'));
$baseDto->setOrderBy($this->getInputAsString('orderBy'));
return $baseDto;
}
}
// Inside a controller method
public function update(MyRequest $request)
{
$baseDto = $request->toDto();
// Now you can use $baseDto->getPerPage() or $baseDto->getOrderBy()
}
use Billyranario\ProstarterKit\App\Helpers;
use Billyranario\ProstarterKit\App\Helpers\LoggerHelper;
// Log a debug message
LoggerHelper::debug('This is a debug message', ['some_data' => 'some_value']]);
// Log an info message
LoggerHelper::info('This is an info message', ['some_data' => 'some_value']]);
// Log a warning message
LoggerHelper::warning('This is a warning message', ['some_data' => 'some_value']]);
// Log a critical message
LoggerHelper::critical('This is a critical message', ['some_data' => 'some_value']]);
// Log an alert message
LoggerHelper::alert('This is an alert message', ['some_data' => 'some_value']]);
// Log an emergency message
LoggerHelper::emergency('This is an emergency message', ['some_data' => 'some_value']]);
// Log an error message
LoggerHelper::error('This is an error message', ['some_data' => 'some_value']]);
// Log an error message
try {} catch (\Throwable $th)
LoggerHelper::logThrowError($th);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.