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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

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


Installation

You can install the package via Composer:

The package will automatically register the StoredProcedureServiceProvider (binding), PaginationServiceProvider (Collection paginate macro), and the StoredProcedure facade alias.

Configuration (optional)

Publish the config file to customize validation and schema defaults:

This creates config/storedproc.php. You can also set these via .env:

Variable Default Description
STORED_PROC_CHECK_EXISTS true Verify the procedure exists before every execute() / run()
STORED_PROC_VALIDATE false Fully validate parameters (count, direction) before execution
STORED_PROC_SCHEMA dbo Default schema when the procedure name has no prefix (SQL Server)
STORED_PROC_CHECK_SYNONYMS false Treat SQL Server synonyms as callable procedures in existence checks

Basic Usage

You can use the Facade (when installed in a Laravel app) or the class directly:

Or use the class directly:

Stored procedure without parameters:

With Pagination

With OUTPUT Parameters (SQL Server & MySQL)

SQL Server Example:

MySQL Example:

The result is returned as a Laravel Collection for easy chaining and manipulation, or as an object with result and output properties when OUTPUT parameters are used.


Method Aliases

All original method names remain supported. Shorter aliases are available for the same behavior:

Original Alias
stored_procedure() procedure()
stored_procedure_connection() connection()
stored_procedure_params() params()
stored_procedure_values() values()
stored_procedure_output_params() outputs()
execute() run()
stored_procedure_result() result()
stored_procedure_output_results() outputResults()

Validation & Existence Checks (v2)

Starting in v2.0.0, every execute() / run() automatically verifies the procedure exists on the database before running it. Disable this to restore v1 behavior:

Full parameter validation

Opt in per call with validate(), or globally via .env:

When validation fails, a ParameterMismatchException is thrown with a message listing what the database expects vs. what you provided.

Check existence without executing

Schema qualification

Unqualified names are resolved automatically:

Override explicitly:

On SQL Server, set STORED_PROC_CHECK_SYNONYMS=true if you call procedures via synonyms and want them to pass existence checks.


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.

Warning: Use this only if your stored procedure does not manage its own transactions (BEGIN, COMMIT, etc.).


OUTPUT Parameters (SQL Server & MySQL)

For stored procedures that return OUTPUT/OUT parameters, you can capture them using the stored_procedure_output_params() method:

SQL Server OUTPUT Parameters

MySQL OUT Parameters

OUTPUT/OUT Parameter Usage

Step 1: Include OUTPUT/OUT parameters in stored_procedure_params() with the appropriate keyword:

For SQL Server:

For MySQL:

πŸ’‘ Example from your use case:

Step 2: Define SQL types in stored_procedure_output_params():

Step 3: Only provide input values in stored_procedure_values():

Smart Result Handling

The package automatically detects if OUTPUT/OUT parameters are used and returns an object with both result (dataset) and output (parameters):


Pagination Support

The package includes a built-in pagination macro for Laravel Collections, making it easy to paginate stored procedure results:

Pagination Features


Example: Full Workflow

This is useful when you want to inject the instance or reuse it across multiple calls. The instance auto-resets after result(); call reset() manually if you need to clear state earlier.


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


Compatibility

Feature Support by Database

Feature MySQL SQL Server
Basic stored procedures βœ… βœ…
Parameters & Values βœ… βœ…
Transactions βœ… βœ…
OUTPUT/OUT Parameters βœ… βœ…
Pagination βœ… βœ…
Logging βœ… βœ…
Existence checks (v2) βœ… βœ…
Parameter validation βœ… βœ…
Synonym support (check) β€” βœ…

Upgrading from v1 to v2

v2.0.0 is backward compatible β€” all v1 method names and chains still work.

Breaking-adjacent changes to be aware of:

  1. Existence checks are on by default. Every execute() / run() verifies the procedure exists before calling it. Set STORED_PROC_CHECK_EXISTS=false to disable.
  2. Call-order errors now throw InvalidCallOrderException (still extends Exception).
  3. Execution is driver-based. CALL vs EXEC is resolved from the active connection, not a global default.

Publish config when you want to tune validation or schema defaults:

See CHANGELOG.md for the full v2 release notes.


Advanced Usage

Complex Stored Procedure with Multiple OUTPUT/OUT Parameters

SQL Server Example:

MySQL Example:

Pagination with Custom Options

Error Handling and Logging

The package throws typed exceptions you can catch individually:

Exception When
StoredProcedureNotFoundException Procedure missing (existence check or DB error)
ParameterMismatchException Parameter count/direction does not match the database
InvalidCallOrderException Fluent methods called in the wrong order
UnsupportedDriverException Connection driver is not MySQL or SQL Server

All extend StoredProcedureException, which extends PHP's Exception.

Reusing StoredProcedure Instances


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:


License

MIT License. Β© Mark Angelo Sollano / magslabs


Credits

Created by @masollano β€” magslabs/laravel-storedproc


All versions of laravel-storedproc with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0 <9.0
laravel/framework Version ^9.0|^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package magslabs/laravel-storedproc contains the following files

Loading the files please wait ...