PHPackages                             caiochami/bundles - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. caiochami/bundles

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

caiochami/bundles
=================

A laravel set of tools for non-laravel projects

v1.9(5y ago)071MITPHPPHP ^7.2|^8.0

Since Nov 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/caiochami/bundles)[ Packagist](https://packagist.org/packages/caiochami/bundles)[ Docs](https://github.com/caiochami/bundles)[ RSS](/packages/caiochami-bundles/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (11)Used By (0)

bundles
=======

[](#bundles)

A laravel-like set of tools for non-laravel projects

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

[](#installation)

\[composer\] composer require caiochami/bundles

Usage
-----

[](#usage)

The \[Request\] class gathers and validates all http input data. If errors are found at the end of validation, it will display the information in json format. That behavior changes when no "Content-Type: application/json" is present in the headers. It will redirect to the previous page with the errors and the request data attached to the $\_SESSION variable.

1. Instantiate the class Request. Passing in a PDO instance is required when using the rule "exists".
2. Specify the rules
3. (Optional) Specify custom messages

Let's say we are seding a json request with the following data.

```
[
    "name" : "John Doe",
    "city" : "",
    "password" : "12345678",
    "password_confirmation" : "1234568",
    "id" : null,
    "patients": [
        {
            "name": "Foo",
            "age": 2
        },
        {
            "name": "Bar",
            "age": 10
        }
    ]
];
```

The validation will be like this:

```
require "vendor/autoload.php";

header("Content-Type: application/json;");

use Bundles\Request;

$request = new Request;

//all empty string variables are converted to null automatically
$request->validate([
    "name" => ["required","string", "minimum:3", "maximum:100"],
    "password" => ["required", "string", "confirmed"],
    "id" => ["nullable", "integer"],
    "patients" => ["required", "array", "gte:1"],
    "patients.*.name" => ["required", "string"],
    "patients.*.age" => ["required", "integer"]
],
[
    "required" => "The field %s is required"
]);
```

Let's assume we have a users table and addresses table. The model class have all the methods you need to create, update, delete and query entries. Check out the following code:

```
 require "vendor/autoload.php";

 use Bundles\Model;
 use Bundles\DatabaseConnection as Database;

 class User extends Model
 {

    protected static $tableName = "users";

    protected static $columns = "id,name,address.city";

    protected static $joins = "";

    protected static $key = "id";

    public function addresses(){
        $addresses = DB::use(self::$conn)
        ->table('addresses')
        ->select(['id', 'city'])
        ->where('user_id', $this->id)
        ->retrieve()
        ->get();

        $this->addresses = $addresses;

    }

 }

class Address extends Model
 {

    protected static $tableName = "addresses";

    protected static $columns = "id,city";

    protected static $joins = "";

    protected static $key = "id";

    protected static $fillable = [ "city" ];

    public function user(){
        $user = DB::use(self::$conn)
        ->table('users')
        ->select(['id', 'name'])
        ->where('id', $this->id)
        ->retrieve()
        ->first();

        $this->user = $user;

    }

    //mutator

    public function setCityAttribute($value){
        return strtolower($value);
    }

 }

 $connection = Database::attempt([
    "db_host" =>  "HOST",
    "db_name" =>  "NAME",
    "db_user" =>  "USER",
    "db_psw" =>  "PASSWORD"
])

 //creating a user
 $user = new User($connection);
 $user->name = "Foo";
 $user->save();

 //or

 $address = Address::create(["city"=> "My homeland"]);

 //finding and updating the user

 $user = User::find($connection, 1);
 //or
 $address = Address::use($connection)->where("id", 1)->first();

 $user->name = "Bar";
 $user->save();

 //or

 User::update($connection, 1, [
     "name" => "Bar"
 ]);

 // deleting a user

 User::destroy($connection, 1);

 $user = User::find($connection, 1);
 $user->delete();

 //querying all addresses

 Address::all($connection);

 //or more specific

 User::use($connection)
 ->where("name", "LIKE", "%bar%")
 ->whereBetween("birthday", "1993-01-01", "2020-01-01"),
 ->orWhere("address.city", "California")
 ->with(['addresses'])
 ->limit(15)
 ->retrieve()
 ->get();

//for debugging you can pass an array just like this
User::find($connection, 1, ["debug" => true]);

//or

User::where("birthday", ">", "1972-11-11")
->orderBy(["name", "DESC"])
->retrieve(["debug" => true, "show_query" => true ])
->get();
```

For more examples, check out the examples/ folder

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~4 days

Total

10

Last Release

1974d ago

PHP version history (2 changes)v1.0PHP &gt;=7.2

v1.9PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f973963262f52ed7fc802664a57365791d45bb42ad08cf8966a97ccf1cd74c2?d=identicon)[caiochami01](/maintainers/caiochami01)

---

Top Contributors

[![caiochami](https://avatars.githubusercontent.com/u/17772351?v=4)](https://github.com/caiochami "caiochami (41 commits)")

---

Tags

requestlaravelvalidatormodelcollection

### Embed Badge

![Health badge](/badges/caiochami-bundles/health.svg)

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

###  Alternatives

[pragmarx/ia-collection

Laravel Illuminate Agnostic Collection

473.4M2](/packages/pragmarx-ia-collection)[pyaesone17/active-state

Active State Checker For Laravel Url

4761.8k2](/packages/pyaesone17-active-state)[werxe/laravel-collection-macros

Custom Laravel Collection macros.

2625.8k](/packages/werxe-laravel-collection-macros)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)

PHPackages © 2026

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