Download the PHP package magslabs/laravel-storedproc without Composer
On this page you can find all versions of the php package magslabs/laravel-storedproc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download magslabs/laravel-storedproc
More information about magslabs/laravel-storedproc
Files in magslabs/laravel-storedproc
Package laravel-storedproc
Short Description This is a custom package for Laravel to utilize/use stored procedures on your laravel application.
License MIT
Informations about the package laravel-storedproc
Laravel-Storedproc
Laravel-Storedproc is a fluent wrapper for calling stored procedures in Laravel — because not every query belongs in Eloquent.
In many real-world applications, especially enterprise systems, stored procedures are a key part of the backend. Laravel doesn’t natively support them in an elegant way, so most developers are stuck writing raw DB::select()
queries over and over.
This package simplifies that.
✨ Features
- ✅ Fluent, chainable syntax for stored procedure calls
- 🧠 Parameter binding from arrays or Laravel requests
- ♻️ Optional Laravel-managed transaction support
- 🔌 Works with MySQL and SQL Server
- 💥 Exception-safe with automatic rollback on failure
📦 Installation
You can install the package via Composer:
🚀 Basic Usage
Or if your stored procedure does not require parameters:
The result is returned as a Laravel Collection for easy chaining and manipulation.
🧩 Parameters & Values
You can pass parameters in multiple formats:
♻️ Transaction Support
Enable Laravel-managed transactions like so:
Laravel will automatically commit on success or roll back if the procedure throws an error.
⚠️ Use this only if your stored procedure does not manage its own transactions (
BEGIN
,COMMIT
, etc.).
🧪 Example: Full Workflow
This is useful when you want to inject the instance or reuse it across multiple calls.
🌐 Switching Database Connections
Need to call a stored procedure on a different connection/database?
This uses Laravel’s connection from config/database.php
.
⚠️ Common Gotchas
-
You must call methods in this order:
stored_procedure()
(required)stored_procedure_params()
(optional, if your proc has parameters)stored_procedure_values()
(required if you set params)with_transaction()
(optional)execute()
(required)stored_procedure_result()
(required)
- All parameters must be bound by position in the
stored_procedure_values()
array.
✅ Compatibility
- Laravel 8, 9, 10, 11, 12
- MySQL, SQL Server (Other databases are not officially supported and may not work as expected)
🔍 Logging Stored Procedure Executions
This package includes built-in logging to help trace and debug stored procedure execution.
✨ Enable a Custom Log File
To log all stored procedure operations into a dedicated log file, add the following channel to your Laravel app’s config/logging.php
: