PHPackages                             tharindu/facade\_generator - 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. tharindu/facade\_generator

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

tharindu/facade\_generator
==========================

A Laravel package to generate facades and services.

v1.0.0(1y ago)20171MITPHPPHP &gt;=8.1

Since Jul 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/TharinduWijayarathna/FacadeGenerator)[ Packagist](https://packagist.org/packages/tharindu/facade_generator)[ RSS](/packages/tharindu-facade-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Laravel Domain Generator
========================

[](#laravel-domain-generator)

*Laravel Domain Generator* is a package that provides a convenient way to generate domain services and facades in your Laravel application.

---

**Installation**

You can install the package via Composer:

```
composer require tharindu/facade_generator
```

**Usage**

To generate a domain service and facade, use the `make:domain` Artisan command:

```
php artisan make:domain User
```

This command will create the following files in the `domain` directory:

- `ServiceNameFacade.php`
- `ServiceNameService.php`

You can then use these files to implement your domain logic.

---

Autoloading the Domain Directory
--------------------------------

[](#autoloading-the-domain-directory)

To ensure Laravel autoloads your custom `domain` directory, you need to update the `composer.json` file of your Laravel application. Follow these steps:

1. **Open your Laravel application's `composer.json` file.**
2. **Locate the `autoload` section.** It should look something like this:

    ```
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    ```
3. **Add your `domain` directory to the PSR-4 autoloading section.** If your domain directory is located at the root of your Laravel application, you can add it like this:

    ```
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Domain\\": "domain/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    ```

    Make sure to adjust the path `"Domain\\"` and `"domain/"` according to the actual structure of your application.
4. **Run `composer dump-autoload`** to regenerate the Composer autoloader files:

    ```
    composer dump-autoload
    ```

Once you've made these changes, Laravel will autoload classes from your `domain` directory just like it does with the `app` directory, making your domain logic easily accessible throughout your application.

---

**Functionalities**

The package provides the following functionalities:

1. **Generation of Domain Service and Facade**: Easily create domain services and facades using the `make:domain` command.
2. **CRUD Functionality**: The generated service stubs include basic CRUD operations for managing domain entities.
    - *Create*: Create new domain entities.
    - *Read*: Retrieve specific domain entities.
    - *Update*: Update existing domain entities.
    - *Delete*: Delete domain entities.
    - *List*: Retrieve a list of domain entities.

---

**Examples**

*Generating a Domain*

To generate a domain service and facade named `User`, run:

```
php artisan make:domain User
```

This will create `UserFacade.php` and `UserService.php` in the `domain` directory.

*Using the Generated Files*

Once the files are generated, you can implement your domain logic inside the service methods. For example:

```
