1. Go to this page and download the library: Download ahmed-arafat/all-in-one 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/ */
ahmed-arafat / all-in-one example snippets
class DatabaseInitialSeedersCommand
{
/**
* Initialize command dependencies.
*/
public function __construct();
/**
* Execute all initial database seeders.
*/
public function handle(): void;
}
class GitCommand
{
/**
* Execute the Git command logic.
*/
public function handle();
}
class PhpMyAdminDatabaseTablesExtractorCommand
{
/**
* Initialize the extractor command.
*/
public function __construct();
/**
* Handle SQL file extraction and processing.
*/
public function handle(): void;
}
class ValidationErrorsAsArrayException
{
/**
* Create a new validation exception instance.
*/
public function __construct(
string $message = "",
int $code = 0,
?Throwable $previous = null
);
}
trait ApiResponser
{
/**
* Build a standardized successful API response.
*/
protected function apiSuccess(
mixed $data = null,
?string $message = null,
array $meta = []
): array;
/**
* Build a standardized error API response.
*/
protected function apiError(
string $message,
array $errors = [],
array $meta = []
): array;
/**
* Build a paginated API response.
*/
protected function apiPaginated(
LengthAwarePaginator $paginator,
?string $message = null
): array;
/**
* Build a simple message-only API response.
*/
protected function apiMessage(string $message): array;
}
trait JsonApiResponser
{
/**
* Return a successful JSON response.
*/
protected function jsonSuccess(
mixed $data = null,
?string $message = null,
int $status = 200,
array $meta = []
): JsonResponse;
/**
* Return an error JSON response.
*/
protected function jsonError(
string $message,
int $status = 400,
array $errors = [],
array $meta = []
): JsonResponse;
/**
* Return a paginated JSON response.
*/
protected function jsonPaginated(
LengthAwarePaginator $paginator,
?string $message = null,
int $status = 200
): JsonResponse;
/**
* Return a message-only JSON response.
*/
protected function jsonMessage(
string $message,
int $status = 200
): JsonResponse;
}
trait CustomRule
{
/**
* Create a strong password validation rule.
*/
public function strongPassword(
int $min = 8,
bool $hasMixed = true,
bool $hasNumbers = true,
bool $hasSymbols = true,
bool $uncompromised = true
): Password;
/**
* Create an exists rule with optional conditions.
*/
public function existsRule(
string $table,
string $column = 'id',
?Closure $whereClosure = null
): Exists;
/**
* Create a unique rule with optional ignore and conditions.
*/
public function uniqueRule(
string $table,
string $column,
?Closure $whereClosure = null,
mixed $ignoreId = null
): Unique;
/**
* Create an exists rule limited to active records.
*/
public function existsActiveRule(
string $table,
string $column = 'id',
string $activeColumn = 'is_active'
): Exists;
/**
* Create a unique rule scoped to a specific column/value.
*/
public function uniqueScopedRule(
string $table,
string $column,
string $scopeColumn,
mixed $scopeValue,
mixed $ignoreId = null
): Unique;
}
trait DateHelper
{
/**
* Parse a date into a Carbon instance.
*/
protected function parseDate(
DateTimeInterface|string $date,
string $timeZone = null
): Carbon;
/**
* Calculate the difference in years, months, and days.
*/
public function diffInYearsMonthsDays(
DateTimeInterface|string $startDate,
DateTimeInterface|string $endDate
): array;
/**
* Check if a date is between two dates.
*/
public function isBetweenDates(
DateTimeInterface|string $date,
DateTimeInterface|string $startDate,
DateTimeInterface|string $endDate
): bool;
/**
* Determine if a date is in the past.
*/
public function isPastDate(DateTimeInterface|string $date): bool;
/**
* Determine if a date is in the future.
*/
public function isFutureDate(DateTimeInterface|string $date): bool;
/**
* Convert a date to ISO format.
*/
public function toIsoDate(DateTimeInterface|string $date): string;
/**
* Format a date using a custom format.
*/
public function formatDate(
DateTimeInterface|string $date,
string $format = 'Y-m-d',
string $timeZone = null
): ?string;
/**
* Calculate age from a birth date.
*/
public function calculateAge(
DateTimeInterface|string $birthDate
): int;
/**
* Add business days to a date.
*/
public function addBusinessDays(
DateTimeInterface|string $date,
int $days
): Carbon;
}
trait ExcelFormatter
{
/**
* Extract data from an uploaded Excel file.
*/
public function excelFileExtractor(
string $fileKey,
bool $likeExcelCells = true,
int $sheetIndex = 0,
bool $skipEmptyCells = true
): array;
}
trait QueryParameter
{
/**
* Resolve a single model from a query parameter.
*/
public function resolveQueryModel(
Request $request,
string $keyName,
string $model,
string $column = 'id'
): ?array;
/**
* Resolve multiple models from a query parameter.
*/
public function resolveQueryModels(
Request $request,
string $keyName,
string $model,
string $column = 'id'
): ?array;
}
trait FilterableTrait
{
/**
* Apply dynamic filtering to a query.
*/
public function scopeFilter(
Builder $q,
string $filterColKey = 'filter_col',
string $filterValKey = 'filter_val'
): Builder;
}
trait SearchableTrait
{
/**
* Apply keyword search to a query.
*/
public function scopeSearch(Builder $q): Builder;
}
trait SortableTrait
{
/**
* Apply dynamic sorting to a query.
*/
public function scopeSortByColumn(
Builder $q,
$target = null,
$dir = null
): Builder;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.