Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Archetype Laravel Package

ajthinking/archetype

Laravel package for defining and instantiating “archetypes” to generate consistent model data and fixtures. Helps standardize defaults, variations, and seeding/test setup by composing reusable templates for your app’s entities.

View on GitHub
Deep Wiki
Context7
v2.0.0
  • Add support for php-parser 5, Drops support for php parser 4.

Thanks to @jasonvarga

v1.1.5

Please see #77 for details.

v1.1.4

This feature provides a BuilderFactory instance when passing a closure to insertStmt.

PHPFile::make()->class(\App\Dummy::class)
  ->astQuery()
  ->class()
  ->insertStmt(function(BuilderFactory $builder) {
	  return $builder->property('someProperty')->getNode();
  })
  ->commit()
  ->end()
  ->preview();
v1.1.3

When astQuery()->insertStmt(.....) had no matches to operate on, it added the node to the end of the file. This was fixed by adding a guard clause.

v1.1.2
  • Improve pretty printing when creating new classes
  • Adds missing types
  • Remove unused dev dependency
  • new ASTQueryBuilder withEach method
  • No more magic for phpparser classmap, use explicit methods instead
  • Fix an issue where weak comparison caused flakiness
v1.1.1
  • Use dependency injection for maker
  • Fix most phpstan level 0 errors
v1.1.0

Makers

PHPFile::make() now return a Maker instance. Makers allows creating files from a template, for instance:

PHPFile::make()->file('scripts.php')
PHPFile::make()->class(\App\Car::class)

We can implement a custom maker and attaching it to the property "maker" on the File instance.

Internal changes

File methods no longer rely on obscure __call magic, instead minimal stubs are implemented to explicitly forward calls to the corresponding endpoint class.

v1.0.3

Avoid Str macros which may cause segmentation fault in statamic/cms

v1.0.2
v1.0.1

Fixes bug when creating classes.

Now we can create classes like so:

namespace App;

PHPFile::make()->class(Models\Car::class);
PHPFile::make()->class(\App\Models\Car::class);
PHPFile::make()->class('App\Models\Car');
PHPFile::make()->class('\App\Models\Car');
PHPFile::make()->class('app/Models/Car.php');

all of these will write two app/Models/Car.php.

v1.0.0

Welcome to v1.0.0 :green_heart:

AstQueryBuilder

  • Adds ability to enter Node class and properties in one go:
$astQuery->classMethod('name->name')
  • Adds HigherOrderWhere which is a short syntax for where callbacks:
$this->file->astQuery()
    ->class()
    ->property()
    ->where->propertyProperty('name->name')->is($key)->get()
    ->replace(function() {
        ...
    };
  • Auto resolving where clauses allows for leaving a where clause without get(). Results are evaluated to see if they have results (considered thruty) or empty (falsy).
  • Adds Dumpable proxies on astQueryBuilder for ->dd->something() and ->dump->another
  • Adds missing PhpParser types in class map
  • Remove option to use _-postfixed node types in class map
  • Adds an opt-in visualizer/debug tool, see: https://github.com/ajthinking/archetype/pull/45
  • Numerous bugfixes

Endpoints

  • Improved ClassConst

Misc

  • fromString can allow pseudo php
PHPFile::addMissingTags()->fromString('$hey = 1337')
  • Allow reading files outside of the input root using an absolute path
  • Add Tappable and Dumpable traits

Discontinued features :warning: :skull:

In order to tighten this package up and consolidate around primary features, we will drop the following incomplete/broken functionality:

  • Schema
  • Project
  • Generators
  • Trait endpoint (planned to be revived in a better form)

Furthermore,

  • Remove aliases for PHPFile and LaravelFile to enforce explicit facade usage
  • Remove doctrine/dbal dependency

Internal changes

  • All tests are moved to pest :rocket:
  • Introduce TestablePHPFile facade.
  • Introduce TestableAstQueryBuilder facade.

Missing and broken

  • The docs are still not near as good as they should be.
  • Some formatting bugs persist. It is most likely related to format preserving pretty printing. See incomplete test
v1.0.0-candidate

Whats new?

  • Adds remove() ability for class constants.

Discontinued features

In order to tighten this package up and consolidate around primary features, we will drop the following:

  • Schema
  • Project
  • Generators

Most of these feature were incomplete or otherwise broken. A side effect of this is we will no longer be depending on doctrine/dbal.

Tests

All tests are moved to pest and many uses an internal TestablePHPFile facade.

v0.2.8

Better array formatting 🎉 🎉 🎉 Works for newly created, loaded or modified code.

class Finally
{
    protected $empty = [];
    
    protected $one = [
        'one',
    ];
    
    protected $moreThanOne = [
        'one',
        'two',
    ];
}

Thanks for spotting this @jackmcdade

v0.2.7

Fixes an issue with doctrine/dbal

v0.2.6

:bug: Fix bug in notInOperator by @ordago 🔒 Allow doctrine/dbal ^2.10 by @WorldSeso7 :white_check_mark: Bump dependecies, typos and test updates

v0.2.5

Include nikic/php-parser as a dependency, don't assume it is included elsewhere.

v0.2.4
v0.2.3

Rename mismatching class name/file name. Fixes #15

v0.2.2

Support for class constant

$file->classConstant('HOME')

Thanks to @seryak

v0.2.1

v0.2.1 :rocket:

  • Tests on Laravel 8
  • Format preserving code manipulation
  • Ignores abstract models
v0.1.3

Don't use facade aliases which might be unavailable.

v0.1.2
v0.1.1

Fix class resolving when using archetype schema in remote context

v0.1.0

Archetype v0.1.0 :rocket:

  • Happy to announce a core set of features including some experiments 🔥
  • This package does not yet strictly follow semver 😬
  • Need feedback 🙏

v0.0.18
v0.0.17
v0.0.16
v0.0.15
v0.0.14
v0.0.13

In the astQuery(), you can now access general classes/objects/structures with ->methodCall() or similar. To enter a property, simply use ->stmts without ()

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport