PHPackages                             veiliglanceren/laravel-oop-config - 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. veiliglanceren/laravel-oop-config

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

veiliglanceren/laravel-oop-config
=================================

Type hinting and autocomplete for config values

0.0.1(11mo ago)00PHPPHP ^8.1CI passing

Since May 19Pushed 11mo agoCompare

[ Source](https://github.com/VeiligLanceren-nl/laravel-oop-config)[ Packagist](https://packagist.org/packages/veiliglanceren/laravel-oop-config)[ RSS](/packages/veiliglanceren-laravel-oop-config/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

Laravel OOP Config
==================

[](#laravel-oop-config)

[![MIT License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

**Laravel OOP Config** is a package that enables developers to generate type-safe, object-oriented wrappers for their Laravel configuration files. This approach provides code completion, type safety, and improved maintainability when working with configuration values.

---

Features
--------

[](#features)

- 🔒 **Type-safe config access:** Generate PHP classes and methods for config files.
- ⚡ **Batch config class generation:** Generate classes for all config files at once.
- 🛠 **Customizable stubs:** Publish and modify the code templates for generated classes and methods.
- 🧩 **Automatic service provider integration:** Seamlessly integrates with Laravel’s service container.
- 📝 **IDE autocompletion:** Enables modern IDEs to provide autocompletion for config keys.
- 🧪 **Tested &amp; reliable:** Includes feature and unit tests for stable operation.

---

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

[](#installation)

Install via Composer:

```
composer require veiliglanceren/laravel-oop-config --dev
```

Publish the configuration file (optional):

```
php artisan vendor:publish --tag=oop-config
```

---

Configuration
-------------

[](#configuration)

After publishing, you can customize the config in `config/oop-config.php`:

- **namespace**: Namespace for generated config classes (default: `App\Config`).
- **path**: Directory path where generated config classes are stored (default: `app/Config`).
- **autoload**: Whether to automatically register generated classes (default: `true`).
- **stubs**: Paths to custom stubs for class and method generation.

---

Usage
-----

[](#usage)

### Generate a Config Class

[](#generate-a-config-class)

To generate a class for a specific config file (e.g., `config/mail.php`):

```
php artisan make:config mail
```

This creates `App\Config\MailConfig`, with methods corresponding to the keys in `mail.php`.

### Generate Classes for All Config Files

[](#generate-classes-for-all-config-files)

```
php artisan config:generate-all
```

Add `--force` to overwrite existing classes:

```
php artisan config:generate-all --force
```

### Accessing Config Values

[](#accessing-config-values)

Use the generated class to access config values with autocompletion and type-safety:

```
use App\Config\MailConfig;

$mailConfig = app(MailConfig::class);

$host = $mailConfig->host();
$fromAddress = $mailConfig->fromAddress();
```

For nested config arrays, methods are generated using camelCase:

```
$fromAddress = $mailConfig->fromAddress();
```

---

Customizing Code Generation
---------------------------

[](#customizing-code-generation)

### Custom Stubs

[](#custom-stubs)

You can customize the generated code by publishing the default stubs:

```
php artisan vendor:publish --tag=stubs
```

Edit the stub files in the published `stubs` directory, then update the `stubs` paths in `config/oop-config.php` if needed.

---

Testing
-------

[](#testing)

This package uses [Pest](https://pestphp.com/). To run the tests:

```
./vendor/bin/pest
```

Ensure your test environment is configured according to Laravel’s testing guidelines.

---

Troubleshooting &amp; FAQ
-------------------------

[](#troubleshooting--faq)

- **Config is not an array:** Ensure that your config files return arrays.
- **Missing or unreadable stub file:** Check the `stubs` path in your config and ensure files exist and are readable.
- **Classes not autoloaded:** Make sure `autoload` is enabled in `oop-config.php`, and clear the config cache if needed.

---

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

[](#contributing)

Contributions are welcome! Please:

1. Fork the repository.
2. Create a feature branch.
3. Write tests for your changes.
4. Submit a pull request.

For suggestions, bug reports, or feature requests, [open an issue](https://github.com/VeiligLanceren-nl/laravel-oop-config/issues).

---

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

---

**Made with ❤️ by [VeiligLanceren.nl](https://veiliglanceren.nl), credits for the idea to [Oussama Mater](https://www.linkedin.com/in/oussamamater) on [LinkedIn](https://www.linkedin.com/feed/update/urn:li:share:7327066187912101889/)**

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance51

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

359d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22b99c08291f57985d16a87bcd5f1a3f4ae2e6332b5e04736b5bf4f0f91c3d19?d=identicon)[VeiligLanceren](/maintainers/VeiligLanceren)

---

Top Contributors

[![NielsHamelink-web](https://avatars.githubusercontent.com/u/67690385?v=4)](https://github.com/NielsHamelink-web "NielsHamelink-web (4 commits)")

---

Tags

autocompletionconfigconfiguration-managementlaravellaravel-packageoopstructural-patternstypehinting

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/veiliglanceren-laravel-oop-config/health.svg)

```
[![Health](https://phpackages.com/badges/veiliglanceren-laravel-oop-config/health.svg)](https://phpackages.com/packages/veiliglanceren-laravel-oop-config)
```

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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