Download the PHP package abdullah-mateen/laravel-helping-material without Composer
On this page you can find all versions of the php package abdullah-mateen/laravel-helping-material. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abdullah-mateen/laravel-helping-material
More information about abdullah-mateen/laravel-helping-material
Files in abdullah-mateen/laravel-helping-material
Package laravel-helping-material
Short Description Laravel helper functions and general helping material
License MIT
Informations about the package laravel-helping-material
Laravel Helping Material
Laravel Helping Material is a Laravel utility package that bundles common helpers, enums, model traits, API response helpers, middleware, resources, and a class-based media upload service.
It is designed for Laravel applications that need reusable project scaffolding plus simple media storage flows such as profile images, documents, temporary uploads, and database-backed media records.
Table Of Contents
- Features
- Requirements
- Installation
- Configuration
- Publishing Files
- Artisan Commands
- Helper Functions
- Upgrade Guide
- Enums
- Models
- Middleware
- Blade Directives
- Response Macros
- Media Service
- Interfaces
- Resources
- Validation Rules
- Examples
- Author
- License
Features
- Helper functions for application config, auth, files, dates, numbers, strings, arrays, pagination, XML, and impersonation.
- PHP backed enums for user, media, temporal, notification, boolean, and status values.
- Model base classes and model traits for common Laravel model behavior.
authorizemiddleware for role-level route authorization.- API response trait and response macros for consistent JSON responses.
- Blade directives for displaying validation errors.
- Class-based
MediaServiceplus typed services:ImageService,AudioService,VideoService,DocumentService, andArchiveService. - Optional publish command for copying config, enums, helpers, middleware, migrations, models, resources, services, and traits into your app.
Requirements
- PHP
^8.1. - Laravel
^10.0,^11.0,^12.0, or^13.0. - PHP extensions:
curl,fileinfo,gd,intl,json, andsimplexml. intervention/image^3.3.
The package is compatible with PHP 8.4 and PHP 8.5, and the test suite has been verified on PHP 8.5.
Installation
Install the package with Composer:
Laravel package auto-discovery registers the service provider automatically. If package discovery is disabled in your project, register the provider manually:
After installation, publish the storage symlink if you store public files:
Configuration
Publish the config when you need to customize models, strict mode, storage, or media extensions:
The config file is published to config/lhm.php.
Important config keys:
Publishing Files
The package supports Laravel vendor publishing and its own interactive publish command.
Publish config only:
Publish migrations only:
Run the interactive package publisher:
lhm:publish shows a menu and lets you publish one or more groups.
| Option | What it publishes | Destination |
|---|---|---|
All |
Every supported publish group | Multiple paths |
Config |
lhm.php config |
config/lhm.php |
Enums |
media and user enum stubs | app/Enums |
Exceptions |
API response exception handler stub | app/Exceptions |
Helpers |
custom helper file stub | app/Helpers/custom.php |
Middlewares |
authorization middleware stub | app/Http/Middleware |
Migrations |
package migrations | database/migrations |
Models |
extended model and media model stubs | app/Models |
Resources |
Sass utility resources | resources/sass |
Services |
app media service extension stub | app/Services/Media |
Traits |
user notification trait stub | app/Traits |
Artisan Commands
php artisan lhm:publish
Publishes package stubs and resources into your application through an interactive checklist.
Use this when you want local editable copies of package files.
php artisan make:lhm-enum
Creates an enum using the package enum stubs. It extends Laravel's enum generator.
php artisan make:lhm-model
Creates a model using the package model stub. It extends Laravel's model generator.
Helper Functions
All package helper functions are documented in HELPER_FUNCTIONS.md.
The package autoloads its own helpers through Composer. If you publish your own helper file with php artisan lhm:publish, add that custom file to your application composer.json:
Then refresh Composer autoloading:
Basic helper examples:
Upgrade Guide
Upgrading from 2.x to 3.x requires reviewing media service usage and any published overrides. See UPGRADE-2.x-TO-3.x.md.
Enums
The package includes reusable PHP enums.
| Namespace | Enums |
|---|---|
AbdullahMateen\LaravelHelpingMaterial\Enums |
BooleanEnum, StatusEnum |
AbdullahMateen\LaravelHelpingMaterial\Enums\Media |
MediaDiskEnum, MediaTypeEnum |
AbdullahMateen\LaravelHelpingMaterial\Enums\Notification |
StatusEnum |
AbdullahMateen\LaravelHelpingMaterial\Enums\Temporal |
DayEnum, MonthEnum, TimeUnitEnum |
AbdullahMateen\LaravelHelpingMaterial\Enums\User |
AccountStatusEnum, GenderEnum, RoleEnum, TitleEnum |
Example enum casts:
Example enum helpers:
Models
The package includes:
ExtendedModel: a base Eloquent model with common package traits.AuthenticatableExtendedModel: a base authenticatable model with common package traits.Media: the default media database model.Notification: the default notification model.
Use the included Media model by default, or override it in config/lhm.php:
If you publish the model stubs, you can customize the app-level models:
Middleware
The package registers authorize middleware automatically.
If you publish and customize the middleware, register your custom alias in your Laravel application and use that alias instead.
Blade Directives
The service provider registers two validation helper directives.
For multiple fields:
Response Macros
The package registers response macros for common API responses.
Set LHM_SNAKE_CASE=true when you want API response keys converted to snake_case.
Media Service
The media service has two layers:
MediaService: the full chainable service.- Typed convenience services:
ImageService,AudioService,VideoService,DocumentService, andArchiveService.
Typed services validate the resolved file type before storing. For example, ImageService only accepts images and DocumentService only accepts documents.
Storage vs Database
store()writes to the filesystem only.persist()writes to the filesystem and inserts media rows in the database.MediaService::store()->save($model)gives chainable control and writes database rows.- Passing
nullas the model stores a database row without amediaablerelation.
Store A Profile Picture And Save It To DB
Store A File Without A Model
Store A DB Row Without A Model Relation
Store Multiple Files
Generate An Image Thumbnail
Store Temporarily, Then Move Later
Move From One Disk To Another
Replace Existing Media
Delete Media
Typed Service Quick Reference
See the full scenario file at examples/media-service-api-examples.php.
Interfaces
ColorsInterface exposes color class and color code constants for consistent enum/UI color handling.
Resources
The package ships Sass utilities for colors, spacing, sizing, borders, and positioning. Publish them with:
They are copied to resources/sass.
Validation Rules
The package includes AbdullahMateen\LaravelHelpingMaterial\Rules\Throttle.
Examples
- Full media API examples: examples/media-service-api-examples.php
- Full helper reference: HELPER_FUNCTIONS.md
Author
Abdullah Mateen - [email protected]
License
The MIT License (MIT) 2024 - Abdullah Mateen. See LICENSE for details.
All versions of laravel-helping-material with dependencies
ext-curl Version *
ext-fileinfo Version *
ext-gd Version *
ext-intl Version *
ext-json Version *
ext-simplexml Version *
google/apiclient Version ^2.18
intervention/image Version ^3.3