internetguru / laravel-common
Installs: 3 102
Dependents: 5
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/internetguru/laravel-common
Requires
- darvis/livewire-injection-stopper: ^1.2
- internetguru/laravel-recaptchav3: ^1.0
- laravel/framework: ^10.0 || ^11.0
- livewire/livewire: ^3.6
- spatie/laravel-ignition: ^2.9
- torann/geoip: ^3.0
Requires (Dev)
- laravel/pint: ^1.25
- livewire/livewire: ^3.6
- orchestra/testbench: ^9.5
- phpunit/php-code-coverage: ^11.0
- dev-main
- v4.7.4
- v4.7.3
- v4.7.2
- v4.7.1
- v4.7.0
- v4.6.4
- v4.6.3
- v4.6.2
- v4.6.1
- v4.6.0
- v4.5.2
- v4.5.1
- v4.5.0
- v4.4.9
- v4.4.8
- v4.4.7
- v4.4.6
- v4.4.5
- v4.4.4
- v4.4.3
- v4.4.2
- v4.4.1
- v4.4.0
- v4.3.0
- v4.2.8
- v4.2.7
- v4.2.6
- v4.2.5
- v4.2.4
- v4.2.3
- v4.2.2
- v4.2.1
- v4.2.0
- v4.1.1
- v4.1.0
- v4.0.0
- v3.0.0
- v2.17.2
- v2.17.1
- v2.17.0
- v2.16.7
- v2.16.6
- v2.16.5
- v2.16.4
- v2.16.3
- v2.16.2
- v2.16.1
- v2.16.0
- v2.15.3
- v2.15.2
- v2.15.1
- v2.15.0
- v2.14.2
- v2.14.1
- v2.14.0
- v2.13.0
- v2.12.6
- v2.12.5
- v2.12.4
- v2.12.3
- v2.12.2
- v2.12.1
- v2.12.0
- v2.11.1
- v2.11.0
- v2.10.2
- v2.10.1
- v2.10.0
- v2.9.0
- v2.8.8
- v2.8.7
- v2.8.6
- v2.8.5
- v2.8.4
- v2.8.3
- v2.8.2
- v2.8.1
- v2.8.0
- v2.7.1
- v2.7.0
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.1
- v2.5.0
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.14.3
- v0.14.2
- v0.14.1
- v0.14.0
- v0.13.2
- v0.13.1
- v0.13.0
- v0.12.1
- v0.12.0
- v0.11.2
- v0.11.1
- v0.11.0
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.0
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.11
- v0.7.10
- v0.7.9
- v0.7.8
- v0.7.7
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.4
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.7
- v0.4.6
- v0.4.5
- v0.4.4
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.1
- v0.3.0
- v0.2.0
- v0.1.0
- dev-dev
- dev-main-4
- dev-staging
- dev-main-3
- dev-main-2
- dev-main-1
- dev-main-0
This package is auto-updated.
Last update: 2026-01-31 20:35:33 UTC
README
This package provides handy utilities for Laravel applications.
| Branch | Status | Code Coverage |
|---|---|---|
| Main | ||
| Staging | ||
| Dev |
Installation
You can install the package via Composer:
composer require internetguru/laravel-common
Run Tests Locally
In Visual Studio Code you can simpy use Ctrl+Shift+B to run the tests.
To run the tests manually, you can use the following commands:
# Build the Docker image docker build -t laravel-common . # Run the tests docker run --rm laravel-common # Both steps combined docker build -t laravel-common . && docker run --rm laravel-common
Helper Methods ~ Globals
The
Helpersclass provides useful methods for Laravel applications.
Configuration and example usage:
-
Add the following lines to the
config/app.phpfile:use Illuminate\Support\Facades\Facade; 'aliases' => Facade::defaultAliases()->merge([ 'Helpers' => InternetGuru\LaravelCommon\Support\Helpers::class, ])->toArray(),
-
Use
Helpersclass methods in your application:<meta name="generator" content="{{ Helpers::getAppInfo() }}"/>
For all available methods, see the Helpers class.
Helper Macros
Package registers a set of useful macros for Carbon and Numbers. See the macros.php file for the complete list.
Example usage:
use Carbon\Carbon; use Illuminate\Support\Facades\Number; Number::useCurrency('USD'); // Set the default currency echo Number::currencyForHumans(1234); // Output (en_US locale): $1,234 echo Number::currencyForHumans(); // Output (en_US locale): $ echo Number::currencyForHumans(1234.567, in: 'EUR', precision: 2); // Output (en_US locale): €1,234.57 app()->setLocale('cs_CZ'); // Set the locale to Czech echo Number::currencyForHumans(1234.567, in: 'EUR', precision: 2); // Output (cs_CZ locale): 1 234,57 € $date = Carbon::parse('2023-12-31'); echo $date->dateForHumans(); // Output (en_US locale): 12/31/2023 $dateTime = Carbon::parse('2023-12-31 18:30:00'); echo $dateTime->dateTimeForHumans(); // Output (en_US locale): 12/31/2023 6:30 PM
CheckPostItemNames Middleware
Middleware that checks for invalid POST parameter names containing dots
".". This middleware helps prevent issues with Laravel's input handling. Throws an exception in non-production environments and logs a warning in production.
To use the middleware for the web group, add the following lines to the bootstrap/app.php file:
$middleware->group('web', [ // ... \InternetGuru\LaravelCommon\Middleware\CheckPostItemNames::class, ]);
Alternatively, you can assign the middleware to specific routes or controllers as needed.
Example:
-
When a POST request contains parameter names with dots:
POST /submit-form Content-Type: application/x-www-form-urlencoded username=johndoe&user.email=johndoe@example.com
-
In Non-Production Environments: The middleware will throw an exception with the message:
Invalid POST parameter names containing dots: user.email -
In Production Environment: The middleware will log a warning:
[WARNING] Invalid POST parameter names containing dots: user.email
Translation Service Provider
Logs missing translations and translation variables in the current language. Throws an exception when not in production environment. In debug mode, checks all available languages.
- Logs warning when a translation key is missing or a variable required in a translation string is not provided.
- Checks all languages in debug mode from all available locales.
- Throws exception
InternetGuru\LaravelCommon\Exceptions\TranslatorExceptioninstead of logging when the app is not in production mode.
To use the provider, add the following lines to the config/app.php file:
use Illuminate\Support\ServiceProvider; 'providers' => ServiceProvider::defaultProviders()->replace([ Illuminate\Translation\TranslationServiceProvider::class => InternetGuru\LaravelCommon\TranslationServiceProvider::class, ])->toArray(),
Carbon Interval Cast
Casts a string to a
CarbonIntervaland back.
Example usage:
use Illuminate\Database\Eloquent\Model; use InternetGuru\LaravelCommon\Casts\CarbonIntervalCast; class Task extends Model { protected $casts = [ 'duration' => CarbonIntervalCast::class, ]; }
Breadcrumb Blade Component
Renders breadcrumb navigation based on routes matching the current URL segments. Supports translations with short and long labels, custom divider, and segment skipping.
Key Features:
- Customizable Divider – Allows a custom divider symbol between breadcrumb items.
- Short and Long Labels – Using
trans_choiceif available shows n-th right translation based on the item positon. - Segment Skipping – Skips a specified number of URL segments. Useful for nested routes or routes with prefixes (e.g. language).
Usage:
<!-- By default, this will generate breadcrumb items based on the current URL path. --> <x-ig::breadcrumb/> <!-- You can change the divider symbol by setting the divider attribute --> <x-ig::breadcrumb divider="|" /> <!-- If you need to skip certain segments of the URL (e.g., a language prefix), use the skipFirst attribute --> <x-ig::breadcrumb :skipFirst="1" />
Example:
- Assuming you have the following routes defined:
<?php Route::get('/', function () { // ... })->name('home'); Route::get('/products', function () { // ... })->name('products.index'); Route::get('/products/{product}', function ($product) { // ... })->name('products.show');
- And your translation files (resources/lang/en/navig.php) include:
<?php return [ 'home' => 'Long Application Name|LAN', 'products.index' => 'All Products|Products', 'products.show' => 'Product Details', ];
- When you visit the
/products/123URL, the short translation will be used for thehomeandproducts.indexroutes.LAN > Products > Product Details - When you visit the
/productsURL, the short label will be used for thehomeroute.LAN > All Products - When you visit the
/URL, the long label will be used for thehomeroute.Long Application Name
System Messages Blade Component
Renders system temporary success messages and persistent error messages in different colors, with a close button.
Include the component in your Blade template where you want the system messages to appear:
<x-ig::system-messages />
Form Blade Components
The package provides a set of Blade components for form and various inputs.
Notes:
- The Google Recaptcha V3 service is enabled by default. To disable it, set the
recaptchaattribute tofalse.
Complete example:
<x-ig::form action="route('test')" :recaptcha="false"/> <x-ig::input type="text" name="name" required>Name</x-ig::input> <x-ig::input type="option" name="simple-options" :value="['a', 'b', 'c']">Simple Options</x-ig::input> <x-ig::input type="option" name="advanced-options" :value="[ ['id' => '1', 'value' => 'User 1' ], ['id' => '2', 'value' => 'User 2' ], ['id' => '3', 'value' => 'User 3' ], ]">Advanced Options</x-ig::input> <x-ig::input type="checkbox" name="checkbox" value="1">Checkbox</x-ig::input> <x-ig::input type="radio" name="radio" value="1">Radio</x-ig::input> <x-ig::input type="textarea" name="description">Description</x-ig::input> <x-ig::submit>Submit Form</x-ig::submit> </x-ig::form>
Language Switch Blade Component
Renders a language switcher as a list of links with the current language highlighted.
Include the component in your Blade template where you want the language switcher to appear:
<x-ig::lang-switch />
License & Commercial Terms
Open Source License
Copyright © 2026 Internet Guru
This software is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.
Disclaimer: This software is provided "as is", without warranty of any kind, express or implied. In no event shall the authors or copyright holders be liable for any claim, damages or other liability.
Commercial Use
The standard CC BY-NC-SA license prohibits commercial use. If you wish to use this software in a commercial environment or product, we offer flexible commercial licenses tailored to:
- Your company size.
- The nature of your project.
- Your specific integration needs.
Note: In many instances (especially for startups or small-scale tools), this may result in no fees being charged at all. Please contact us to obtain written permission or a commercial agreement.
Contact for Licensing: info@internetguru.io
Professional Services
Are you looking to get the most out of this project? We are available for:
- Custom Development: Tailoring the software to your specific requirements.
- Integration & Support: Helping your team implement and maintain the solution.
- Training & Workshops: Seminars and hands-on workshops for your developers.
Reach out to us at info@internetguru.io — we are more than happy to assist you!