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

Forms Laravel Package

nette/forms

Nette Forms is a PHP form-building library for creating secure, reusable web forms with built-in validation, CSRF protection, rendering helpers, and easy component composition. Integrates smoothly with Nette Framework but works standalone in any PHP app.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Decoupled Design: Clean separation between form logic (PHP) and client-side validation (TypeScript-based netteForms.js), enabling progressive enhancement without tight coupling.
    • Nette Ecosystem Synergy: Native integration with Latte templates (v3.1.15+) and Nette DI, reducing boilerplate for PHP applications already using these tools. For non-Nette Laravel apps, the package can still be leveraged via standalone usage (e.g., FormFactory in v3.1.2).
    • Modern PHP Features: Full support for PHP 8.1–8.5, including enums, strict types, and constructor property promotion (v3.2.4+), aligning with Laravel’s current stack.
    • Security-First: Built-in CSRF protection (SameSite cookies), input sanitization, and validation rules (e.g., addEmail(), addInteger()) reduce Laravel’s need for manual validation logic (e.g., replacing Laravel’s Request::validate() for complex forms).
    • Client-Side Validation: netteForms.js provides real-time validation (e.g., data-nette-rules), reducing reliance on Laravel’s frontend frameworks (e.g., Livewire, Inertia) for form logic.
  • Cons:

    • Non-Nette Overhead: Laravel’s service container and Blade templating require adapters (e.g., wrapping FormFactory in a Laravel service provider) to integrate seamlessly. The package assumes Nette’s Application context, which may need mocking or abstraction.
    • Template Engine Lock-in: While Latte is optional, Laravel’s Blade would need custom renderers (e.g., extending DefaultFormRenderer) to replicate Latte macros ({formPrint}, {input}). The package’s Blueprint feature (v3.1.15) could mitigate this by generating Blade-compatible HTML.
    • Event System: Nette’s event-driven validation (e.g., onValidate) differs from Laravel’s service container events. Bridging this (e.g., via Laravel’s Events facade) adds complexity.
    • CSRF Handling: Nette’s SameSite cookie-based CSRF conflicts with Laravel’s XSRF-TOKEN. Requires custom middleware to coexist or disable one system.

Integration Feasibility

  • Laravel Compatibility:

    • PHP Version: v3.2+ requires PHP 8.1+ (Laravel 9+), while v3.1 supports PHP 7.2–8.0 (Laravel 8–). Recommend v3.2.x for Laravel 10+.
    • Dependency Conflicts: No direct conflicts with Laravel core, but Nette’s Http and Utils may require version pinning (e.g., nette/http:^3.1).
    • Template Engine: Blade lacks native support, but Blueprint (v3.1.15) can generate static HTML or be adapted for Blade. Example:
      // Laravel Service Provider
      public function register() {
          $this->app->singleton('nette.form.factory', function () {
              return new \Nette\Application\UI\FormFactory();
          });
      }
      
    • Validation Rules: Laravel’s Validator and Nette’s Rules can coexist, but custom rules (e.g., addCallback()) may need Laravel-specific adapters.
  • Key Integration Points:

    Nette Forms Feature Laravel Equivalent Integration Approach
    FormFactory Laravel’s FormRequest Wrap FormFactory in a Laravel service.
    Latte macros ({formPrint}) Blade directives Create custom Blade components or use Blueprint.
    netteForms.js Laravel Mix/Vite + Alpine.js Include JS bundle via Laravel’s asset pipeline.
    CSRF protection Laravel’s VerifyCsrfToken Disable one or create middleware to merge logic.
    Container::getValues() Laravel’s Validator::validate() Use for DTO hydration or pre-validate with Nette.

Technical Risk

  • High:

    • Template Engine Mismatch: Blade’s lack of native support for Nette macros could require significant customization (e.g., rewriting DefaultFormRenderer for Blade).
    • CSRF Conflict: Merging Nette’s SameSite CSRF with Laravel’s XSRF-TOKEN may introduce edge cases (e.g., double validation).
    • Event System Gaps: Nette’s onValidate events won’t integrate natively with Laravel’s Events facade, requiring manual bridging.
    • Type Safety: While Nette’s PHP 8.5 types are robust, Laravel’s dynamic nature (e.g., dynamic properties) may clash with Nette’s strict typing (e.g., addInteger() rejecting null by default).
  • Medium:

    • Learning Curve: Team familiarity with Nette’s Container/Control hierarchy may require training for Laravel developers accustomed to Laravel’s Request/Validator.
    • Testing Overhead: Client-side validation (netteForms.js) adds complexity to Laravel’s test suite (e.g., testing both server and client rules).
  • Low:

    • Performance: Nette Forms is optimized for PHP 8+, with minimal overhead compared to Laravel’s native validation.
    • Maintenance: Active development (latest release 2026-05-26) and clear deprecation policies reduce long-term risk.

Key Questions

  1. Template Strategy:

    • Will the team adapt Blueprint for Blade or build custom renderers? What’s the trade-off between flexibility and maintenance?
    • Example: Should DefaultFormRenderer be extended to output Blade-compatible HTML?
  2. CSRF Management:

    • How will Nette’s SameSite CSRF coexist with Laravel’s XSRF-TOKEN? Will one be disabled, or will middleware merge both?
  3. Validation Workflow:

    • Will Nette Forms replace Laravel’s Validator entirely, or will it handle only specific cases (e.g., complex forms)? How will validation errors be merged into Laravel’s Validator::errors()?
  4. Client-Side Integration:

    • How will netteForms.js be integrated with Laravel’s frontend stack (e.g., Alpine.js, Inertia)? Will it replace or complement existing client-side validation?
  5. Dependency Isolation:

    • Should Nette Forms be isolated in a micro-service or tightly coupled to Laravel’s service container? What’s the impact on caching (e.g., FormsExtension::getCacheKey())?
  6. Enum/DTO Support:

    • How will Nette’s Container::getValues(MyEnum::class) integrate with Laravel’s DTOs or Model binding? Will it replace or supplement Laravel’s Fillable traits?
  7. Migration Path:

    • What’s the phased rollout plan? Start with standalone forms (e.g., contact pages) before replacing core validation logic?

Integration Approach

Stack Fit

  • Primary Use Cases:

    • Form-Heavy Applications: Registration, checkout, surveys, or admin panels where validation complexity justifies a dedicated library.
    • Nette-Laravel Hybrids: Applications using both Nette (e.g., legacy modules) and Laravel (e.g., new APIs).
    • Security-Critical Forms: Forms requiring CSRF protection, file upload validation, or strict input sanitization.
  • Laravel-Specific Adaptations:

    • Service Provider: Register FormFactory as a Laravel singleton, with optional bindings for FormRenderer and Validator adapters.
      // app/Providers/NetteFormsServiceProvider.php
      public function register() {
          $this->app->singleton(\Nette\Application\UI\FormFactory::class, function () {
              $factory = new FormFactory();
              $factory->setTranslator($this->app['translator']);
              return $factory;
          });
      }
      
    • Blade Integration: Create a custom Blade component or extend DefaultFormRenderer to output Blade syntax:
      // app/View/Components/NetteFormComponent.php
      class NetteFormComponent extends Component {
          public function render(): string {
              $form = resolve(FormFactory::class)->create();
              // ... configure form
              return view('components.nette-form', ['form' => $form]);
          }
      }
      
    • Validation Adapter: Bridge Nette’s Rules to Laravel’s Validator:
      // app/Services/NetteValidatorAdapter.php
      class NetteValidatorAdapter {
          public static function adapt(Nette\Forms\Rules $rules): array {
              $laravelRules = [];
              foreach ($rules as $rule) {
                  $laravelRules[] = match ($rule) {
                      'Email' => 'email',
                      'Required' => 'required',
                      // ...
      
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope