PHPackages                             diego-rlima/artisan-make-file-location - 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. diego-rlima/artisan-make-file-location

AbandonedArchivedLibrary

diego-rlima/artisan-make-file-location
======================================

Ability to change the namespace/location of the files generated by the "artisan make" commands.

1.5.1(5y ago)112.1k2[1 issues](https://github.com/diego-rlima/artisan-make-file-location/issues)MITPHPPHP &gt;=7.1.0

Since May 17Pushed 5y ago1 watchersCompare

[ Source](https://github.com/diego-rlima/artisan-make-file-location)[ Packagist](https://packagist.org/packages/diego-rlima/artisan-make-file-location)[ RSS](/packages/diego-rlima-artisan-make-file-location/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (7)Dependencies (1)Versions (9)Used By (0)

diego-rlima/artisan-make-file-location
======================================

[](#diego-rlimaartisan-make-file-location)

Ability to change the namespace/location of the files generated by the "artisan make" commands.

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

[](#requirements)

This package requires **Laravel 5.4 or later** and **PHP 7.1.0 or later**.

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

[](#installation)

```
$ composer require diego-rlima/artisan-make-file-location
```

For Laravel 5.4, you must register the service provider of this package. Add the code below in the **providers** section of your `config/app.php` file.

```
DRL\AMFL\ArtisanServiceProvider::class,
```

Using
-----

[](#using)

You can use all "artisan make" commands as usual. But now, you can add the options **--prefix** and **--suffix** to change the namespace of your files.

**Note:** For files that do not have namespace (like migrations), only the prefix can be used.

### Prefix

[](#prefix)

```
$ php artisan make:controller ProductController --prefix=Units\\Products\\Controllers
```

This will output the file with the namespace **App\\Units\\Products\\Controllers**.

### Suffix

[](#suffix)

```
$ php artisan make:controller ProductController --suffix=Products
```

This will output the file with the namespace **App\\Http\\Controllers\\Products**.

### Both Prefix and Suffix

[](#both-prefix-and-suffix)

```
$ php artisan make:controller ProductController --prefix=Units --suffix=Products
```

This will output the file with the namespace **App\\Units\\Controllers\\Products**.

Customizing
-----------

[](#customizing)

The package is configured to be compatible with the Laravel standard, but allowing you to set prefixes and suffixes. However, you can replace the Laravel pattern with your own.

Publish the config using the following command:

```
$ php artisan vendor:publish --provider="DRL\AMFL\ArtisanServiceProvider"
```

Now you have a [config/amfl.php](https://github.com/diego-rlima/artisan-make-file-location/blob/master/config/amfl.php) file. The settings are divided between files that have namespaces and files that they do not have.

```
return [
    /*
    |--------------------------------------------------------------------------
    | Files namespaces
    |--------------------------------------------------------------------------
    */
    // List of all files with namespace. Eg.:
    'controller' => '{root}\{prefix|default:Http}\Controllers\{suffix}',
    'test' => '{root}\{prefix}\{type}\{suffix}',

    /*
    |--------------------------------------------------------------------------
    | Files locations
    |--------------------------------------------------------------------------
    */
    // List of all files without namespace. Eg.:
    'seeder' => '{root}/{prefix}/seeds/{name}.php',
];
```

For files with namespace, the **{root}** normally will be replaced by the "App" namespace. Of curse, **{prefix}** and **{suffix}** will be replaced by the prefix and suffix you choose.

In the test files, **{root}** will be changed to "Tests" namespace. These files also have namespace variation. The **{type}** will be changed to "Unit" or "Feature".

For files without namespace, the **{root}** will be replaced by the root directory of application. The **{prefix}** and **{name}** will be replaced by the prefix and the file name, respectively.

**Important:** If you are going to create the migrations in another folder, make sure the folder is already created, or the migration will not be created. This is due to the way the original command was written.

### Making prefixes/suffixes required

[](#making-prefixessuffixes-required)

All you have to do is add `|required` to the file configuration. Eg.:

```
return [
    // Now you will always have to enter a prefix when creating a Model.
    'model' => '{root}\{prefix|required}',

    // The same for the notification suffix.
    'notification' => '{root}\{prefix}\Notifications\{suffix|required}',
];
```

### Defining a default value for prefixes/suffixes

[](#defining-a-default-value-for-prefixessuffixes)

Just add `|default:YouDefaultValue` to the file configuration. Eg.:

```
return [
    // Now, if you do not set a prefix, the default value will be used.
    'model' => '{root}\{prefix|default:Models}',

    // The same for the suffix.
    'rule' => '{root}\{prefix}\Rules\{suffix|default:Admin}',
];
```

**Note:** Default values will not be applied if prefix/suffix is required.

### Extending other commands

[](#extending-other-commands)

Do you want to use prefixes / suffixes in your commands or third-party commands? Just do it!

Let's assume that your command class looks like the following:

```
namespace App\Console\Commands;

use Illuminate\Console\GeneratorCommand;

class FooBarMakeCommand extends GeneratorCommand
{
    protected $name = 'make:foobar';

    protected $description = 'Create a new bar';

    protected $type = 'FooBar';

    protected function getStub()
    {
        return __DIR__ . '/stubs/bar.stub';
    }

    protected function getDefaultNamespace($rootNamespace)
    {
        return $rootNamespace.'\Foo\Bar';
    }
}
```

You need to change the class so that it can retrieve the pattern we set. It will be similar to:

```
use DRL\AMFL\TraitCommand;

class FooBarMakeCommand extends GeneratorCommand
{
    // You will use trait.
    use TraitCommand;

    // You will use the amflCustomNamespace() method to retrieve the correct namespace and return it in the getDefaultNamespace() method.
    protected function getDefaultNamespace($rootNamespace)
    {
        return $this->amflCustomNamespace($rootNamespace);
    }

    // You will create the amflInit() method and load the correct settings.
    protected function amflInit()
    {
        $this->amflCommandSetup('foobar'); // "foobar" must be the configuration key within your "config/amfl.php" file;
    }

    // Code omitted
}
```

If your command will generate a file without namespace, the code must change a bit. It should look like:

```
use DRL\AMFL\TraitCommand;

class FooBarMakeCommand extends GeneratorCommand
{
    use TraitCommand;

    // You will use the amflCustomPath() method to retrieve the correct path and return it in the getPath() method.
    protected function getPath($name)
    {
        $rootPath = $this->laravel->basePath();

        return return $this->amflCustomPath($rootPath, $name);
    }

    protected function amflInit()
    {
        $this->amflCommandSetup('foobar');
    }
}
```

In your AppServiceProvider, extend the list of commands.

```
use DRL\AMFL\CommandsList;
use App\Console\Commands\FooBarMakeCommand;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        // The first argument must be the name of the command. The second is a function that receives the $app variable and returns an instance of the command class.
        CommandsList::extend('command.foobar.make', function ($app) {
            return new FooBarMakeCommand($app['files']);
        });
    }
}
```

Put the pattern configuration of the command inside your "config/amfl.php" file.

```
return [
    // For files with namespace.
    'foobar' => '{root}\{prefix}\Foo\{suffix}',

    // For files without namespace.
    'foobar' => '{root}/{prefix}/Foo/{name}.php',
];
```

List of commands supported
--------------------------

[](#list-of-commands-supported)

CommandSupports prefixSupports suffixMin. Laravel Versionmake:channelyesyes**5.6**make:commandyesyes**5.4**make:controlleryesyes**5.4**make:eventyesyes**5.4**make:exceptionyesyes**5.6**make:factoryyesno**5.6**make:jobyesyes**5.4**make:listeneryesyes**5.4**make:mailyesyes**5.4**make:middlewareyesyes**5.4**make:migrationyesno**5.4**make:modelyesno**5.4**make:notificationyesyes**5.4**make:policyyesyes**5.4**make:provideryesyes**5.4**make:requestyesyes**5.4**make:resourceyesyes**5.6**make:ruleyesyes**5.6**make:seederyesno**5.4**make:testyesyes**5.4**

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

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

Recently: every ~206 days

Total

7

Last Release

2092d ago

PHP version history (5 changes)1.0PHP &gt;=5.6.4

1.1PHP &gt;=7.0

1.2PHP &gt;=7.1.3

1.3PHP &gt;=7.0.0

1.5PHP &gt;=7.1.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22944913?v=4)[Diego Ribeiro](/maintainers/diego-rlima)[@diego-rlima](https://github.com/diego-rlima)

---

Top Contributors

[![diego-rlima](https://avatars.githubusercontent.com/u/22944913?v=4)](https://github.com/diego-rlima "diego-rlima (18 commits)")

### Embed Badge

![Health badge](/badges/diego-rlima-artisan-make-file-location/health.svg)

```
[![Health](https://phpackages.com/badges/diego-rlima-artisan-make-file-location/health.svg)](https://phpackages.com/packages/diego-rlima-artisan-make-file-location)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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