Installation
Requirements
Before installing Laravel Form, make sure you have:
- PHP >= 8.0.1 (8.1+ recommended)
- Laravel >= 9.19 (9/10/11 supported)
- Composer
- jobmetric/laravel-package-core ^1.34
- jobmetric/laravel-custom-field ^2.1
Install via Composer
Run the following command to pull in the latest version:
composer require jobmetric/laravel-form
Service Provider
Laravel Package Auto-Discovery will automatically register the service provider. If you're using Laravel < 5.5 or have disabled auto-discovery, manually register the provider in config/app.php:
'providers' => [
// ...
JobMetric\Form\FormServiceProvider::class,
],
Publish Configuration
After installation, publish the configuration file (optional):
php artisan vendor:publish --provider="JobMetric\Form\FormServiceProvider" --tag="form-config"
This will create a config/form.php file where you can customize package settings.
Publish Views
If you want to customize the form rendering views, publish them:
php artisan vendor:publish --provider="JobMetric\Form\FormServiceProvider" --tag="form-views"
This will copy the form views to resources/views/vendor/form/ where you can customize them.
Verify Installation
To verify the package is installed correctly, you can test building a form:
use JobMetric\Form\FormBuilder;
$form = FormBuilder::make()
->action('/test')
->method('POST')
->tab(function ($tab) {
$tab->id('test')
->label('Test Tab')
->group(function ($group) {
$group->label('Test Group')
->customField(function ($field) {
$field->text()
->name('test')
->label('Test Field')
->build();
})
->build();
})
->build();
})
->build();
$html = $form->toHtml();
// If no errors occurred, installation is successful!
Next Steps
Now that you've installed Laravel Form, you can:
- Learn about building forms
- Explore real-world examples
- Check out the complete API reference
Troubleshooting
FormBuilder Methods Not Found
If you get "Method not found" errors:
- Make sure the package is properly installed via Composer
- Run
composer dump-autoload - Clear any opcode cache (OPcache) if enabled
- Ensure
laravel-custom-fieldis properly installed
Custom Fields Not Available
If custom field methods are not available:
- Verify
laravel-custom-fieldis installed:composer show jobmetric/laravel-custom-field - Ensure custom fields are registered in their service provider
- Run
php artisan custom-field:ideto regenerate IDE helpers
Views Not Found
If you get "View not found" errors:
- Make sure the service provider is registered
- Check that blade views are published (if using custom templates)
- Verify the package views are accessible
Validation Not Working
If validation doesn't work with FormBuilderRequest:
- Ensure the form builder is properly set:
$request->setFormBuilder($formBuilder) - Check that custom fields have validation rules configured
- Verify the request is using
FormBuilderRequestas the base class