PHPackages                             scriptpage/framework - 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. scriptpage/framework

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

scriptpage/framework
====================

Core code of the Scriptpage framework

v3.1.2(1y ago)16232MITPHP

Since May 7Pushed 1y agoCompare

[ Source](https://github.com/tuliogoncalves/scriptpage)[ Packagist](https://packagist.org/packages/scriptpage/framework)[ RSS](/packages/scriptpage-framework/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (20)Used By (0)

Scriptpage Framework[1](#user-content-fn-1-758b3a631f6072fccc7c2dd3ee86c573)
============================================================================

[](#scriptpage-framework1)

v3.0
----

[](#v30)

> **Note:** This repository contains the core code of the Scriptpage framework. If you want to build an application using Laravel with scriptpage, you need know [Scriptpage Sail](https://github.com/tuliogoncalves/sail).

#### See a MVC Starter with VueJS using scriptpage: [starter-with-vuejs](https://github.com/tuliogoncalves/starter-with-vuejs)

[](#see-a-mvc-starter-with-vuejs-using-scriptpage-starter-with-vuejs)

You want to know a little more about the Repository pattern? [Read this great article](http://scriptpage.com.br/using-scriptpage-repository).

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
    - [Composer](#composer)
    - [Laravel](#laravel)
        - [JWT Authorization](#jwtauthorization)
        - [Application Version]()
        - [Global Exception]()
- [URL Query Filters](#methods)
    - [RepositoryInterface](#filters)
    - [Filters](#prettusrepositorycontractsrepositorycriteriainterface)
- [Usage](#usage)
    - [Create a Model](#create-a-model)
    - [Use methods](#use-methods)
    - [Create a Criteria](#create-a-criteria)
    - [Using the Filter in a Controller](#using-the-filter-in-a-controller)

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

[](#installation)

#### Composer

[](#composer)

Execute the following command to get the latest version of the package:

```
composer require scriptpage/framework

```

#### Laravel

[](#laravel)

Execute the following command to install componente on project:

```
php artisan vendor:publish --tag=scriptpage-install

```

To enable helpers.php file, add in composer.json:

```
    "autoload": {
        "psr-4": {
        ...
        },
        "files": [
            "app/helpers.php"
        ]
```

Then, execute the following command to reload componentes on project:

```
composer dumpautoload -o

```

Add in api or web route file:

```
Route::middleware('auth')->group(function () {

    /**
     * Home routes
     */
    addRoute('web/home');

    /**
     * Users routes
     */
    addRoute('web/users');

});

/**
 * Auth routes
 */
addRoute('api/auth');

/**
 * Users routes
 */
Route::prefix('v1')->group(function () {
        addRoute('api/users');
});
```

#### JWT Authorization

[](#jwt-authorization)

Execute the following commands to install and configure JWT package with scriptpage:

```
composer require tymon/jwt-auth
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\LaravelServiceProvider"
php artisan jwt:secret
php artisan vendor:publish --tag=scriptpage-jwt

```

Inside the config/auth.php make the following changes to the file:

```
'defaults' => [
    'guard' => 'api',
    'passwords' => 'users',
],

...

'guards' => [
    'api' => [
        'driver' => 'jwt',
        'provider' => 'users',
    ],
],
```

Add trait in Models\\User class.

```
...

use App\Traits\traitUserJWT;

class User extends Authenticatable implements JWTSubject
{
  ...

  use traitUserJWT;
```

Add in App\\Http\\Kernel class.

```
protected $middlewareAliases = [
        ...

        'auth' => \Scriptpage\Middleware\EnsureUserAuth::class,
];
```

#### Role permissions

[](#role-permissions)

Execute the following commands to install and configure role permissions of scriptpage:

```
php artisan vendor:publish --tag=scriptpage-role

```

Add in App\\Http\\Kernel class.

```
protected $middlewareAliases = [
        ...

        'roles' => \Scriptpage\Middleware\EnsureUserHasRole::class,
];
```

#### Global Exception

[](#global-exception)

Defining a global exception on your application's in App\\Exceptions\\Handler@register class.

```
use Scriptpage\Traits\traitApiRenderableResponse;

class Handler extends ExceptionHandler
{
        use traitApiRenderableResponse;

        ...

        $this->renderable(function (Exception $e, Request $request) {
                return $this->apiRenderableResponse($e, $request);
        });
```

#### Application Version

[](#application-version)

Add this lines in Config/App.php file:

```
'version' => env('APP_VERSION', '1.0.0'),
'project_name' => env('APP_PROJECT_NAME', 'app'),
```

URL Query Filters
-----------------

[](#url-query-filters)

#### filters

[](#filters)

- select = $column1,$column2,...
- with = $relation1,$relation2,...
- withCount = $relation1,$relation2,...
- withSum = $relation:$column
- where = $column,\[$condition = 'equal'\]:$value
- orWhere = $column,\[$condition = 'equal'\]:$value
- join = $table:$field1,$field2
- leftJoin = $table:$field1,$field2
- rightJoin = $table:$field1,$field2
- take = $limit
- skip = $offset
- orderBy = $column:\[$direction = 'asc'\]
- groupBy = $column1,$column2,...
- having = $column,\[$condition = 'equal'\]:$value
- orHaving = $column,\[$condition = 'equal'\]:$value
- paginate = true|false

> array is separated by semicolons, example: expresion1; expression2; expresion3...

#### Conditions

[](#conditions)

- equal( = )

    ```
      $field:$value

    ```
- greater( &gt; )

    ```
      $field,greater:$value

    ```
- greater\_or\_equal( &gt;= )

    ```
      $field,greater_or_equal:$value

    ```
- less( &lt; )

    ```
      $field,less:$value

    ```
- less\_or\_equal( &lt;= )

    ```
      $field,less_or_equal:$value

    ```
- different ( &lt;&gt; )

    ```
      $field,different:$value

    ```
- null\_safe ( &lt;=&gt; )

    ```
      $field,null_safe:$value

    ```
- in

    ```
      $field,in:$value1,$value2,$value3...

    ```
- not\_in

    ```
      $field,in:$value1,$value2,$value3...

    ```
- like

    ```
      $field,like:$pattern

      $pattern, examples:

              _value*
              value*
              *value_*

    ```
- not\_like

    ```
      $field,like:$pattern

    ```
- between

    ```
      $field,between:$value1, $value2

    ```
- not\_between

    ```
      $field,not_between:$value1, $value2

    ```

Examples
--------

[](#examples)

#### Using repository by request

[](#using-repository-by-request)

#### Model

[](#model)

- get `api/users`

#### With clausule

[](#with-clausule)

- get `api/users?select=id,name,email&with=roles`

#### Where clausule

[](#where-clausule)

- get `api/users?where=role_id:2`
- get `api/users?where=role_id:2;name:ester`
- get `api/users?where=role_id:2&orWhere=name:ester`
- get `api/users?where=role_id,between:34,52`
- get `api/users?where=email_verified_at:2023-05-14 14.02.20`

#### to Sql

[](#to-sql)

Show sql statement result

- get `api/users/sql?where=email_verified_at:2023-05-14 14.02.20`

#### selecting fields

[](#selecting-fields)

- get `api/model/users?select=id,name,email`

#### Database

[](#database)

- get `api/users/db?select=name,email&where=id,greater:200`

#### Add relationship

[](#add-relationship)

get `api/table/users?join=contacts:users.id,contacts.user_id`

```
get api/table/users
    ?join=contacts:users.id,contacts.user_id
    ;orders:users.id,orders.user_id
    &where=users.name:laravel
    &select=users.*,contacts.phone,orders.price

```

Laravel Eloquent Query: Using WHERE with OR AND OR
--------------------------------------------------

[](#laravel-eloquent-query-using-where-with-or-and-or)

#### Make use of [Logical Grouping](https://laravel.com/docs/master/queries#logical-grouping)

[](#make-use-of-logical-grouping)

```
    Model::where(function ($query) {
    $query->where('a', '=', 1)
            ->orWhere('b', '=', 1);
    })->where(function ($query) {
    $query->where('c', '=', 1)
            ->orWhere('d', '=', 1);
    });

```

#### With parameters for a,b,c,d

[](#with-parameters-for-abcd)

```
$a = 1;
$b = 1;
$c = 1;
$d = 1;
Model::where(function ($query) use ($a, $b) {
    return $query->where('a', '=', $a)
        ->orWhere('b', '=', $b);
})->where(function ($query) use ($c, $d) {
    return $query->where('c', '=', $c)
        ->orWhere('d', '=', $d);
});

```

Footnotes
---------

1. A framework is an abstraction that links common code across multiple software projects to provide generic functionality. A framework can achieve specific functionality, by configuration, during application programming. Unlike libraries, it is the framework that dictates the flow of control of the application, called Inversion of Control..[wikipedia](https://pt.wikipedia.org/wiki/Framework) [↩](#user-content-fnref-1-758b3a631f6072fccc7c2dd3ee86c573)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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.

###  Release Activity

Cadence

Every ~35 days

Recently: every ~81 days

Total

16

Last Release

573d ago

Major Versions

v1.3.0.x-dev → v2.0.22023-06-27

v2.1.5.x-dev → v3.02023-12-03

### Community

Maintainers

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

---

Top Contributors

[![tuliogoncalves](https://avatars.githubusercontent.com/u/12338418?v=4)](https://github.com/tuliogoncalves "tuliogoncalves (138 commits)")

---

Tags

jwtlaraveleloquentrepositoryurl query string

### Embed Badge

![Health badge](/badges/scriptpage-framework/health.svg)

```
[![Health](https://phpackages.com/badges/scriptpage-framework/health.svg)](https://phpackages.com/packages/scriptpage-framework)
```

###  Alternatives

[okaybueno/laravel-repositories

A package that provides a neat implementation to integrate the Repository pattern in Laravel with Eloquent.

1816.1k](/packages/okaybueno-laravel-repositories)[dannyweeks/laravel-base-repository

An abstract repository class for your Eloquent repositories that requires minimal config to get started.

202.0k](/packages/dannyweeks-laravel-base-repository)

PHPackages © 2026

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