Getting Started
The utils package is a versatile utility toolkit designed to enhance Laravel applications. It provides a variety of reusable classes and functions to streamline development, including CSS and JavaScript assets to support frontend components like buttons, modals, and tables.
Easily integrate the package into your project, publish assets, and selectively include only the styles and functions you need for a highly customizable setup. Perfect for Laravel developers seeking to simplify their workflow with ready-to-use utilities.
Installation
composer require patrikjak/utils
Setup
After installing the package, add the package provider to the providers array in bootstrap/providers.php.
use Patrikjak\Utils\UtilsServiceProvider; return [ ... UtilsServiceProvider::class,];
Next, publish the package assets:
php artisan vendor:publish --tag="assets" --force
Usage
The Utils package offers a variety of useful classes and functions.
CSS
To include all component styles, add the main.css file:
<link rel="stylesheet" href="{{ asset('vendor/pjutils/assets/main.css') }}">
You need to set border-box box-sizing for all elements in your CSS file to prevent layout issues:
* { box-sizing: border-box;}
JavaScript
This package does not include a compiled JavaScript file. Instead, import and call functions directly within your main JavaScript file.
Refer to the documentation for a list of available functions and usage examples.
Dependencies
Utils requires the following dependencies to function properly:
npm install i18n-js axios
To load correct language for JS you need to set lang attribute to html tag
<!DOCTYPE html><html lang="sk">...
You will need to set up vite build target to esnext in your vite.config.js file:
export default defineConfig({ ... build: { target: 'esnext', },});