Create code by imagining public apis

v0.1.0 2022-06-01 08:50 UTC

This package is auto-updated.

Last update: 2022-08-04 05:53:20 UTC


Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Imagine public API:s and make it so - a TDD and sketch toy for Laravel projects 🤩


Getting started

Install and enable like so:

composer require ajthinking/anything --dev
php artisan anything:on

Then, flesh out your idea and execute it in a console context. Lets say we want to build a git client:

// This class does not exist, yet
  ->build() // <-- creates the class!

The last method call ->build() will create this class for you along with all the method stubs:


namespace App\Support;

class Git
    public static function client()
        return new static();
    public function pull()
        return $this;
    public function add()
        return $this;

	// ...

When referenced statically like above the first call will typically spawn a static method. However, if the class name contains Facades\ lets say App\Facades\Zonda we will instead make it an instance method and create a facade next to it:


namespace App\Support\Facades;

use Illuminate\Support\Facades\Facade;

class Zonda extends Facade
    protected static function getFacadeAccessor()
        return 'App\\Zonda';

Finally, make sure to clean up by discarding the change in bootstrap/app.php with git, or by running php artisan anything:off


This experiment comes with some limitations.

  • anything:on/off commands it makes a little intrusion in your bootstrap/app.php to temporary swap out the console kernel. It assumes you have not made any major modifications to this file.
  • it will only work for classes in the App namespace
  • method arguments are currently ignored
  • assumes everything returns $this
  • when using in tests, make sure your test case uses CreatesApplication. This might not always be the case for unit test setups


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