PHPackages                             vicgutt/laravel-models-finder - 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. vicgutt/laravel-models-finder

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

vicgutt/laravel-models-finder
=============================

Find all models in your Laravel app or package

v0.1.1(3y ago)01.5k1MITPHPPHP ^8.1

Since Jan 15Pushed 3y ago1 watchersCompare

[ Source](https://github.com/VicGUTT/laravel-models-finder)[ Packagist](https://packagist.org/packages/vicgutt/laravel-models-finder)[ Docs](https://github.com/vicgutt/laravel-models-finder)[ RSS](/packages/vicgutt-laravel-models-finder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (12)Versions (3)Used By (1)

Find all models in your Laravel app or package
==============================================

[](#find-all-models-in-your-laravel-app-or-package)

[![GitHub Tests Action Status](https://github.com/vicgutt/laravel-models-finder/actions/workflows/run-tests.yml/badge.svg)](https://github.com/vicgutt/laravel-models-finder/actions/workflows/run-tests.yml)[![GitHub PHPStan Action Status](https://github.com/vicgutt/laravel-models-finder/actions/workflows/phpstan.yml/badge.svg)](https://github.com/vicgutt/laravel-models-finder/actions/workflows/phpstan.yml)[![GitHub Code Style Action Status](https://github.com/vicgutt/laravel-models-finder/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/vicgutt/laravel-models-finder/actions/workflows/fix-php-code-style-issues.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/21de2bec27a49f57470e1b9ed2b8ab60f765a53420b85cd1391a1e33f1381c0e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766963677574742f6c61726176656c2d6d6f64656c732d66696e6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vicgutt/laravel-models-finder)[![Total Downloads](https://camo.githubusercontent.com/ec9070e1edb3af14897c8aeaa667dae40720fc90a8af2f0bb356ba0d8e206e64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766963677574742f6c61726176656c2d6d6f64656c732d66696e6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vicgutt/laravel-models-finder)

---

This package allows you to find and retrieve all Laravel models in a given folder. A "model" is any class extending `Illuminate\Database\Eloquent\Model`.

Here's a quick example:

```
// On an app containing only the default Laravel "User" model, running:
$models = ModelsFinder::find()
    ->map(static fn (ModelData $model): array => [
        'path' => $model->path,
        'class' => $model->class,
    ])
    ->toArray();

// would return the following:
[
    [
        'path' => '/[...]/my-project/app/Models/User.php',
        'class' => '\App\Models\User',
    ],
]
```

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

[](#installation)

You can install the package via composer:

```
composer require vicgutt/laravel-models-finder
```

Usage
-----

[](#usage)

You can initiate the discovery of models by using the `find` static method.

```
$models = ModelsFinder::find(
    directory: app_path('Models'),
    basePath: base_path(),
    baseNamespace: '',
);
```

This method accepts 3 optional arguments:

- `directory`: The directory in which to recusively start searching for models. Defaults to `app_path('Models')`.
- `basePath`: The autoloaded entry directory of the project where the search will be initiated. Defaults to `base_path()`.
- `baseNamespace`: The autoloaded base namespace of the project where the search will be initiated. Defaults to `''`.

The `basePath` &amp; `baseNamespace` properties will most likely correspond to an autoloaded entry in a `composer.json` file. Example:

```
{
    "autoload": {
        "psr-4": {
            // Base namespace       |  Base path
            "Spatie\\MediaLibrary\\": "src"
        }
    }
}
```

Here's an example showcasing searching for a model in the `vendor` folder:

```
ModelsFinder::find(
    directory: base_path('vendor/spatie/laravel-medialibrary'),
    basePath: base_path('vendor/spatie/laravel-medialibrary/src'),
    baseNamespace: 'Spatie\MediaLibrary'
)->toArray(),

// would return the following:
[
    [
        'path' => '[...]/vendor/spatie/laravel-medialibrary/src/MediaCollections/Models/Media.php',
        'class' => 'Spatie\MediaLibrary\MediaCollections\Models\Media',
    ],
]
```

The return value of the method is a lazy collection *(`Illuminate\Support\LazyCollection`)*.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

If you're interested in contributing to the project, please read our [contributing docs](https://github.com/vicgutt/laravel-models-finder/blob/main/.github/CONTRIBUTING.md) **before submitting a pull request**.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Victor GUTT](https://github.com/vicgutt)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity45

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

Total

2

Last Release

1154d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88ae8f0fc220c28b6b5effd3b319d26ee05cf51066c42d72b606d57dad308ae6?d=identicon)[vicgutt](/maintainers/vicgutt)

---

Top Contributors

[![VicGUTT](https://avatars.githubusercontent.com/u/39224143?v=4)](https://github.com/VicGUTT "VicGUTT (2 commits)")

---

Tags

laravelmodelsphpphplaravelmodels

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/vicgutt-laravel-models-finder/health.svg)

```
[![Health](https://phpackages.com/badges/vicgutt-laravel-models-finder/health.svg)](https://phpackages.com/packages/vicgutt-laravel-models-finder)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[tapp/filament-google-autocomplete-field

Filament plugin that provides a Google Autocomplete field

3098.1k](/packages/tapp-filament-google-autocomplete-field)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

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