PHPackages                             yab/cerebrum - 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. yab/cerebrum

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

yab/cerebrum
============

The easiest way to add some mental magic to any part of your Laravel/Lumen app.

v1.1.3(8y ago)820.2kMITPHPPHP &gt;=5.6.4

Since Jul 8Pushed 8y agoCompare

[ Source](https://github.com/YABhq/Cerebrum)[ Packagist](https://packagist.org/packages/yab/cerebrum)[ RSS](/packages/yab-cerebrum/feed)WikiDiscussions develop Synced 4w ago

READMEChangelogDependencies (5)Versions (12)Used By (0)

Cerebrum
========

[](#cerebrum)

**Cerebrum** - The easiest way to add some mental magic to any part of your Laravel/Lumen app.

- Memory provides magic caching abilities.
- Linguistics provides a means of simple NLP.
- Perception helping you discover data you didn't even know you had

**Author(s):**

- [Matt Lantz](https://github.com/mlantz) ([@mattylantz](http://twitter.com/mattylantz), matt at yabhq dot com)

Requirements
------------

[](#requirements)

1. PHP 5.6+
2. Lumen 5.2+
3. Laravel 5.2+

### Composer

[](#composer)

Start a new Laravel project:

```
composer create-project laravel/lumen your-project-name
```

Then run the following to add Cerebrum

```
composer require yab/cerebrum
```

### Providers

[](#providers)

```
Yab\Cerebrum\CerebrumProvider::class
```

#### For Lumen:

[](#for-lumen)

Add this to the `bootsrap/app.php` in the service providers array:

#### For Laravel:

[](#for-laravel)

Add this to the `config/app.php` in the service providers array:

Milestones
----------

[](#milestones)

### 1.0

[](#10)

- Memory
- Linguistics

### 1.1

[](#11)

- Perception

Memory Example
--------------

[](#memory-example)

```
use Yab\Cerebrum\Memory;

class TaskService
{
    use Memory;

    public function __construct(TaskRespository $taskRepository)
    {
        $this->repository = $taskRepository;
        // provided by Memory
        $this->memoryDuration(15);
        $this->forgetful([
            'all'
        ]);
    }

    public function all()
    {
        return $this->remember($this->repository->all());
    }

    public function findById($id)
    {
        return $this->remember($this->repository->findById($id));
    }

    public function findByIdWithLongerCache($id)
    {
        return $this->remember($this->repository->findById($id), 1440);
    }

    public function update($id, $data)
    {
        $this->forget($id);
        return $this->repository->update($id, $data);
    }
}
```

Regarding `$this->forgetful` if you do not set it, then `Memory` will parse your class for all functions and clear any related caches it can find.

The `remember` function on the other hand, will collect a value and store it in the cache, returning the cached version. The `forget` with a parameter will find caches with similar values and clear your caches.

Linguistics Example
-------------------

[](#linguistics-example)

```
use Yab\Cerebrum\Linguistics;

class TaskService
{
    use Linguistics;

    public function __construct(TaskRespository $taskRepository)
    {
        $this->repository = $taskRepository;
    }

    public function getKeyWords($id)
    {
        return $this->getKeyWords($this->repository->findById($id)->text);
    }

    public function search($searchString)
    {
        if ($this->isQuestion($seachString)) {
            return $this->repository->search();
        }
    }
}
```

Perception Examples
-------------------

[](#perception-examples)

```
use Yab\Cerebrum\Perception;

class TaskService
{
    use Perception;

    public function __construct(TaskRespository $taskRepository)
    {
        $this->repository = $taskRepository;
    }

    public function getNormalizedData()
    {
        $scores = $this->repository->pluck('score')->all();
        return $this->normalize($scores);
    }

    public function predictDay()
    {
        $records = $this->repository->pluck('day', 'sleep_hours', 'active_hours')->all();
        // $records = ['monday' => [6, 1], 'wednesday' => [4, 0]]
        $result = $this->supervised()->samples($records)->predict([5,2]);
        // $result = monday
    }

    public function getExpectingDay()
    {
        // This is a very simple frequency tool
        $records = $this->repository->pluck('day')->all();
        // $records = ['monday', 'tuesday', 'wednesday', 'tuesday', 'friday', 'monday', 'tuesday']
        $result = $this->ai()->samples($records)->expecting();
        // $result = tuesday
    }
}

## License
Cerebrum is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

### Bug Reporting and Feature Requests
Please add as many details as possible regarding submission of issues and feature requests

### Disclaimer
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community6

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

Recently: every ~102 days

Total

8

Last Release

3154d ago

Major Versions

v0.1.0 → v1.0.02016-07-13

PHP version history (2 changes)v0.1.0PHP &gt;=5.5.9

v1.0.2PHP &gt;=5.6.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/81d026d950739c978b844ac79e6b454e7fedc95ceffdcc4da09893c2497c7255?d=identicon)[mlantz](/maintainers/mlantz)

---

Top Contributors

[![mlantz](https://avatars.githubusercontent.com/u/1065551?v=4)](https://github.com/mlantz "mlantz (31 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yab-cerebrum/health.svg)

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

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.1k91.3M282](/packages/laravel-horizon)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.7M64](/packages/spatie-laravel-responsecache)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40140.4k2](/packages/erlandmuchasaj-laravel-gzip)

PHPackages © 2026

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