PHPackages                             shini/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. shini/laravel-storedprocedures

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

shini/laravel-storedprocedures
==============================

test

09PHP

Since Apr 8Pushed 11y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/36d7e8d71fcff56503f2cbc8f6804d28f616ca5826e6d8b1df134e2d972394db/68747470733a2f2f7472617669732d63692e6f72672f6d72626c61636b75732f6c61726176656c2d73746f72656470726f636564757265732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mrblackus/laravel-storedprocedures)

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

[](#laravel-stored-procedures)

This package allow you to work with PostgreSQL stored procedures with Laravel 4. 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

```
"mrblackus/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 can override default configuration by publishing configuration file and editing it.

```
php artisan config:publish mrblackus/laravel-storedprocedures

```

You can change the database schema to read and the directory where models for stored procedures are written.

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

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

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/fbbb55535cab0a38c4c21b2490d6d1e9392a741cfa0e77bb427734724a3b72c8?d=identicon)[shinigami35](/maintainers/shinigami35)

---

Top Contributors

[![shinigami35](https://avatars.githubusercontent.com/u/2971070?v=4)](https://github.com/shinigami35 "shinigami35 (1 commits)")

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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