PHPackages                             3ie/laravel-storedprocedures - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. 3ie/laravel-storedprocedures

ActiveLibrary[Database &amp; ORM](/categories/database)

3ie/laravel-storedprocedures
============================

0.1.3(11y ago)21.5k1PHPPHP &gt;=5.4.0

Since Sep 2Pushed 11y ago5 watchersCompare

[ Source](https://github.com/3IE/laravel-storedprocedures)[ Packagist](https://packagist.org/packages/3ie/laravel-storedprocedures)[ RSS](/packages/3ie-laravel-storedprocedures/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

[![Build Status](https://camo.githubusercontent.com/10b6918485bd7f5c779460320a6d487006dc7b55736c7167d7c737985db256c7/68747470733a2f2f7472617669732d63692e6f72672f3369652f6c61726176656c2d73746f72656470726f636564757265732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/3ie/laravel-storedprocedures)

Laravel stored procedures
=========================

[](#laravel-stored-procedures)

This package allow you to work with PostgreSQL stored procedures with Laravel 5. It allows you to generate models to simply use your procedures in your PHP code.

Installation
------------

[](#installation)

### Package installation

[](#package-installation)

#### With Composer

[](#with-composer)

Require this package by adding following dependency on your composer.json

```
"3ie/laravel-storedprocedures": "0.1.*"
```

Then update composer with `composer update` or `composer install`.

#### With Laravel bundle

[](#with-laravel-bundle)

If you do not want to use Composer, you can install it by using Laravel Bundle by typing this command

```
php artisan bundle:install StoredProcedure

```

### Registering service provider

[](#registering-service-provider)

Once the package is installed, add the ServiceProvider in `providers` array on app/config/app.php :

```
'providers' => array(
    'Mrblackus\LaravelStoredprocedures\LaravelStoredproceduresServiceProvider'
);
```

Usage
-----

[](#usage)

You can generate model for your stored procedures (aka *functions*) by typing this command

```
php artisan generate-sp

```

**Only stored procedures which name start with `sp_` will have a model generated, other ones will be ignored.**Models will be written in app/store\_procedures directory (or the one defined in configuration file). **Do not edit these models !** They will be overwritten at next generation.

Configuration
-------------

[](#configuration)

You have to run the vendor:publish method to copy the configuration file into you app directory

```
php artisan vendor:publish

```

You can change the database schema to read and the directory where models for stored procedures are written. You can also modify the namespace used for your sp\_models

```
return array(
    'schema'         	=> 'public',
    'model_save_dir' 	=> 'stored_procedures/',
	'model_namespace'   => 'App'
);
```

Models
------

[](#models)

Generated models have an `execute()` methods that allow you to execute stored procedure and get result (if the procedure returns one) from it.

If procedure have IN or INOUT parameter, the `execute()` method will have the same parameter in the same order.

If it has OUT or INOUT parameter, model will have an attribute with getter/setter for every OUT parameters.

**Setters will not modify data**, they are only present to allow you to format data if you want to use it on views by uysing whole model instead of simple variables.

Example
-------

[](#example)

Giving the following stored procedure, that retrieve all friends of a user giving its id...

```
CREATE OR REPLACE FUNCTION sp_getfriends(IN id integer, OUT id integer, OUT username character varying, OUT firstname character varying, OUT lastname character varying, OUT facebook_id character varying)
  RETURNS SETOF record AS
$BODY$SELECT id, username, firstname, lastname, facebook_id
FROM users
LEFT JOIN friends ON users.id = friends.friend_with_id
WHERE friends.user_id = $1$BODY$
  LANGUAGE sql VOLATILE
  COST 100
  ROWS 1000;
```

...we will have a `SP_Getfriends` class generated. We can use it like this :

```
$userId = 20;
$friends = SP_Getfriends::execute($userId);

$firstFriend = $friends[0];
$friend->getId();
$friend->getUsername();
$friend->getFacebookid();
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~75 days

Total

4

Last Release

4049d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ea032d603c4de21d4785eb25004074597acdff0fbbcafc1abdda570aaf047880?d=identicon)[3ie](/maintainers/3ie)

---

Top Contributors

[![mrblackus](https://avatars.githubusercontent.com/u/2353980?v=4)](https://github.com/mrblackus "mrblackus (16 commits)")[![3ieCedricSchneider](https://avatars.githubusercontent.com/u/14056197?v=4)](https://github.com/3ieCedricSchneider "3ieCedricSchneider (1 commits)")

### Embed Badge

![Health badge](/badges/3ie-laravel-storedprocedures/health.svg)

```
[![Health](https://phpackages.com/badges/3ie-laravel-storedprocedures/health.svg)](https://phpackages.com/packages/3ie-laravel-storedprocedures)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[aglipanci/laravel-eloquent-case

Adds CASE statement support to Laravel Query Builder.

115157.2k](/packages/aglipanci-laravel-eloquent-case)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
