Download the PHP package unquam/nette-maker without Composer
On this page you can find all versions of the php package unquam/nette-maker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download unquam/nette-maker
More information about unquam/nette-maker
Files in unquam/nette-maker
Package nette-maker
Short Description CLI code generator for Nette Framework: scaffold modules, migrations, seeders, factories, authentication, API resources, form requests and more.
License MIT
Informations about the package nette-maker
unquam/nette-maker
A CLI code generator for Nette Framework. Scaffold presenters, models, repositories, services, Latte templates, and database migrations with a single command — without touching boilerplate ever again.
Requirements
| Dependency | Version |
|---|---|
| PHP | >= 7.4 |
| symfony/console | ^5.0 \|\| ^6.0 \|\| ^7.0 |
| nette/php-generator | ^3.5 \|\| ^4.0 |
| nette/neon | ^3.3 \|\| ^4.0 |
| doctrine/inflector | ^2.0 |
Optional:
nette/diis required only when integrating viaMakerExtensionin your Nette DI config.
Installation
Since this package is a Composer Plugin, during installation Composer will ask:
Do you trust "unquam/nette-maker" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?]
Press y to allow. The plugin will automatically create two files in your project root:
| File | Purpose |
|---|---|
nette |
Executable PHP runner — run php nette <command> |
nette-maker.neon |
Configuration file (database credentials, migrations path) |
If you pressed n, create the runner manually:
Configuration
Edit nette-maker.neon in your project root:
| Key | Type | Description |
|---|---|---|
database.dsn |
string |
PDO DSN — driver is auto-detected from the prefix (mysql, pgsql, sqlite, sqlsrv) |
database.user |
string |
Database username |
database.password |
string |
Database password |
migrations.directory |
string |
Path relative to the config file where migration files are stored (default: db/migrations) |
Usage
All commands are available through the php nette runner or through vendor/bin/nette-maker.
Available Commands
| Command | Description |
|---|---|
make:init |
Create the default nette-maker.neon config file |
make:presenter <Name> |
Generate a Presenter class |
make:model <Name> |
Generate a Model class |
make:repository <Name> |
Generate a Repository class |
make:service <Name> |
Generate a Service class |
make:latte <Name> |
Generate a Latte template |
make:request <Module/Name> |
Generate an API Form Request validation class |
make:request <Module/Name> --web |
Generate a Web Frontend Form Request class |
make:test <Module/Name> |
Generate a Nette Tester test class |
make:test <Module/Name> --phpunit |
Generate a PHPUnit test class |
make:module <Name> |
Generate a full module (all of the above) |
make:auth |
Scaffold full authentication system |
make:resource <Name> |
Generate a JSON API resource transformer |
make:seeder <Name> |
Generate a database seeder class |
make:factory <Name> |
Generate a database factory class |
make:migration <Name> |
Generate a migration file |
migrate |
Run pending migrations |
migrate --rollback |
Roll back all ran migrations |
migrate --status |
Show migration status |
migrate:fresh |
Drop all tables and re-run all migrations |
migrate:fresh --seed |
Drop all tables, re-run migrations and seed |
db:seed |
Run all database seeders |
db:seed --class=Name |
Run a specific seeder class |
db:wipe |
Drop all database tables |
clear:cache |
Clear application cache directories |
make:init
Creates nette-maker.neon in the project root.
If the file already exists the command exits with a warning and does nothing.
make:presenter
Generates a Presenter class in app/Presentation/<Name>/<Name>Presenter.php.
Generated class:
make:model
Generates a Model class in app/Model/<Name>.php that uses Nette\Database\Explorer.
Generated class:
make:repository
Generates a Repository class in app/Model/Repositories/<Name>Repository.php.
Generated class includes findAll(): Selection, findById(int $id), create(array $data), update(int $id, array $data): bool and delete(int $id): bool methods pre-wired to the correct database table via a private TABLE constant.
make:service
Generates a Service class in app/Model/Services/<Name>Service.php, pre-injecting the corresponding Repository.
make:latte
Generates an empty Latte template at app/Presentation/<Name>/default.latte.
Form Requests (make:request)
Encapsulate your form input validation logic inside standalone, highly testable Request classes structured beautifully within your Feature Folders.
Generating Requests
By default, it generates an API-specific request class (inside the Api/Requests/{Module} namespace):
To generate a Web Frontend specific request class (inside the Requests/{Module} namespace):
1. Configuration Example (StoreRequest.php)
Define your validation rules using core constraints (required, nullable, sometimes, string, integer, numeric, boolean, array, email, email:rfc, email:dns, email:rfc,dns, url, min:n, max:n, min_length:n, max_length:n, in:a,b, not_in:a,b, regex:/pattern/, confirmed, date, date_format:Y-m-d, before:date, after:date, alpha, alpha_num, alpha_dash, digits:n, digits_between:a,b, between:a,b, ip, ipv4, ipv6, uuid, json, accepted, declined, filled, present, prohibited, size:kb, mimetypes:types).
Note: Use
email:dnsoption with caution in high-traffic production environments, as DNS lookups introduce synchronous network latency.
Rules can be defined as a pipe-separated string or as an array:
2. Multilingual Support (Czech / Multi-lang)
...
The RuleValidator uses dynamic placeholder tokens (:field, :min, :max, :values). You can easily return error messages in Czech (or any other language) by overriding them directly in the messages() method of your request class, or by passing translated strings through your architecture.
Example Czech Output Mapping:
If you override messages for Czech localization:
Usage in Presenters (Safe Action Flow)
Case A: Usage in a REST API Presenter (JSON Output)
Czech API Validation Failure Output (422 Client Error):
Case B: Usage in a Web Frontend Presenter (HTML Forms with Redirect)
3. Database Validation (unique / exists)
Pass the Explorer instance as second constructor argument to enable database-backed rules:
Usage in Presenter:
If
Exploreris not passed,uniqueandexistsrules are silently skipped.
Test Generation
make:test
Generate test classes for Nette Tester (default) or PHPUnit. The command automatically analyzes the target class using reflection and scaffolds test methods for all its public actions.
💡 Note: To run default tests, make sure you have
nette/testerin your dev dependencies.
Interactive Mode
If you run the command without arguments, it will ask for the class name interactively:
Real-world Nested Example
If your project has a deep folder structure (e.g., app/Model/Security/Authenticator.php), just pass the path relative to your app directory:
The tool will dynamically build the correct nested test structure:
- Target Location:
tests/Unit/Model/Security/AuthenticatorTest.phpt - Smart Imports: Automatically generates
use App\Model\Security\Authenticator; - Bootstrap Resolution: Dynamically calculates directory depth (
require __DIR__ . '/../../../bootstrap.php';)
Smart Features:
- Method Auto-Scaffolding: Reads public methods from your class and generates matching
testMethodName()boilerplate blocks. - Smart Namespaces: Dynamically detects your dev-dependencies autoloading settings from
composer.json. - Zero Config Setup: Automatically creates a fully functional
tests/bootstrap.phpfor Nette Tester if it's missing in your project.
make:module
Scaffolds a complete module in one command: Presenter, Model, Repository, Service, Migration, and Latte template.
All parts are optional. Skip specific ones with --no-* flags:
Generate only specific parts with --only:
Comma-separated values accepted: presenter, model, repository, service, migration, latte.
Authentication Scaffolding (make:auth)
Scaffold a fully operational authentication, registration, and logout system out-of-the-box. It automatically generates a secure database schema migration table script, custom security Authenticator model services compliant with Nette Security standards, controller presenter forms logic handlers, and responsive front-end view templates layouts:
What gets generated:
db/migrations/%timestamp%_create_users_table.php— Secure table structure handling password storage hashing hashes.app/Model/Security/Authenticator.php— DB credentials comparison core evaluating identities rules.app/Presentation/Sign/SignPresenter.php— Controller factories mapping login (signInForm), registration (signUpForm), and clean session logouts (actionOut).app/Presentation/Sign/in.latte&up.latte— Styled UI templates interfaces ready to serve layout pages.
Activation setup rules:
Once generated, simply wire up the fresh class service structure boundary mapping inside your core Nette application DI container tracking block configuration setup (config.neon layout configuration file):
Afterward, instantly run your migrations schema setup to provision your backend database tracking table structures allocation layouts:
API Resources & Collections (make:resource)
Transform your database models into secure, structured JSON layers with native support for Nette Framework pagination.
Generating Resources
To generate a single item transformer resource (extends JsonResource):
To generate a paginated resource collection transformer (extends ResourceCollection):
1. The Single Item Resource (UserResource.php)
Safely filter your database fields inside the toArray() block to prevent sensitive credentials leaks:
2. The Resource Collection (UserCollection.php)
Define which single item resource class should map the nesting loop:
Usage in Presenters
Case A: Single Item Response
Case B: Paginated Collection Response
Natively maps Nette Database query streams (Selection) combined with pagination settings out-of-the-box:
JSON Output Format:
🔐 REST API Authentication Integration
If you need to protect these generated JSON endpoints with lightweight, secure bearer access/refresh tokens, use our native companion API package:
It provides full token life-cycle management, strict CORS controls, and built-in rate-limiting filters out-of-the-box.
make:seeder
Generates a database seeder class stub.
Configure the seeders directory in nette-maker.neon:
Data Factories (make:factory)
Generate powerful blueprint schemas for your database records to simplify seeding and testing.
Configure your custom factories lookup directory path inside nette-maker.neon:
Inside the Factory Class
Each generated factory is a structured PHP class extending AbstractFactory. You can easily map default attributes using standard PHP or external libraries like Faker:
Usage in Seeders
Since generated blueprints are native PHP classes, you get complete IDE autocompletion. Simply instantiate the factory inside your seeders context loop using a standard object constructor:
make:migration
Generates a timestamped migration file in the configured migrations directory.
Generated migration:
TableBuilder API
Supported database drivers: mysql, mariadb, pgsql/postgres, sqlite, sqlsrv/mssql.
migrate
Run all pending migrations:
Show migration status:
Roll back all ran migrations:
migrate:fresh
Drops all database tables completely and re-runs all migration scripts sequentially from scratch. This provides a fresh starting state for local development:
You can automatically run database seeders right after resetting your database schema using the --seed (or -s) shortcut flag:
db:seed
Run all available seeders alphabetically:
Run a specific seeder class directly using the --class (or -c) option:
db:wipe
Completely drops all tables from the database without running down() migration methods. It safely disables foreign key constraints internally during the process:
clear:cache
Safely clears application cache and maintenance directories.
By default, it targets the temp/ folder. It uses smart isolation: inside the standard Nette temp/ directory, it removes only the compiled configuration and templates (temp/cache/ and temp/proxies/), strictly ignoring temp/session/ so active web users won't log out.
You can configure multiple custom directories to be fully cleared inside your nette-maker.neon configuration array:
Interactive Prompts
All code generation commands support a smart interactive mode. If you forget to provide the name argument, the CLI will prompt you for it in real-time:
Directory Structure Generated
Running the commands creates files in the following locations (all relative to your project root by default, or to the directory containing nette-maker.neon when using the nette runner):
Integration with Nette DI (MakerExtension)
If your project uses nette/di, you can register all commands as services and wire them into your Symfony Console application via the DI extension.
1. Register the extension in your config.neon
2. Use the Application service in your bootstrap
The extension registers every make:* command and the migrate command as individual DI services. This allows them to participate in standard DI autowiring.
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feat/my-feature. - Write tests for any new behaviour in
tests/. - Ensure the test suite passes:
composer test. - Follow PSR-12 coding standards.
- Open a pull request against the
mainbranch.
License
This package is open-sourced software licensed under the MIT licence.
All versions of nette-maker with dependencies
composer-plugin-api Version ^2.0
symfony/console Version ^5.0||^6.0||^7.0
nette/php-generator Version ^3.5||^4.0
nette/neon Version ^3.3||^4.0
doctrine/inflector Version ^2.0