PHPackages                             ray/ray-di-for-laravel - 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. ray/ray-di-for-laravel

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

ray/ray-di-for-laravel
======================

Ray.Di for Laravel

0.6.0(3mo ago)528.6k↓34.7%2MITPHPPHP &gt;=8.0CI passing

Since Oct 15Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/ray-di/Ray.RayDiForLaravel)[ Packagist](https://packagist.org/packages/ray/ray-di-for-laravel)[ RSS](/packages/ray-ray-di-for-laravel/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (7)Used By (0)

Ray.Di for Laravel
==================

[](#raydi-for-laravel)

DI+AOP, done the right way
--------------------------

[](#diaop-done-the-right-way)

English | [Japanese](README.ja.md)

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

[](#installation)

```
composer require ray/ray-di-for-laravel

```

Use
---

[](#use)

Copy the module that describes the binding, the context, and the directory where the generated files will be stored.

```
cp -r vendor/ray/ray-di-for-laravel/RayDi app
cp -r vendor/ray/ray-di-for-laravel/storage/ storage

```

Change the following lines in `bootstrap/app.php`.

```
+ $basePath = $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__);
+ $context = getenv('APP_ENV') ?: 'local';
- $app = new Illuminate\Foundation\Application(
-     $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
- );
+ $app = new Ray\RayDiForLaravel\Application(
+     $basePath,
+     App\RayDi\Context\ContextProvider::get($basePath, $context)
+ );
```

Add the `Ray\RayDiForLaravel\Attribute\Injectable` Attribute to classes or interfaces you want to resolve by Ray.Di.

This class will be resolved by Ray.Di.

```
