Download the PHP package reecem/static-form without Composer
On this page you can find all versions of the php package reecem/static-form. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reecem/static-form
More information about reecem/static-form
Files in reecem/static-form
Package static-form
Short Description Handle static form submissions in Laravel app
License MIT
Homepage https://static-form.laravelpkg.dev
Informations about the package static-form
Handle static form submissions and other static site things in Laravel app
Handle Static form submissions inside your Laravel app from Next.JS and Netlify or any other static site server.
Installation
You can install the package via composer:
To install the application you can do the following:
This will install the config file and the service provider, you can though opt for each one separately or use the following:
You can publish the config file with:
You can publish the Service Provider file with:
You will need to add the following to the config/app.php
file:
You can view the docs here https://static-form.pkgpg.dev
Usage
As an overview, the usage of the current version is that you can use the packages middleware on controllers that you define, this will then use your controller to handle the request data.
Create The Token
The first step is to generate your token, to do that you can use the console command:
This will generate your token, it will show you the plain text version only during that session.
The other way is to call the API endpoint to generate a new one. The API is secured via the Gate that is defined in the App\Providers\StaticFormServiceProvider::class
You can define any logic in there that would allow only authorized people to access the application.
To call the API endpoint, for now you can make a request to the endpoint through a custom UI and javascript code.
Method | Endpoint | Description | |
---|---|---|---|
GET | domain.tld/api/static-form/token | This will return a 200 status and the static-form package version if the toke is found | |
POST | PATCH | domain.tld/api/static-form/token | A POST or PATCH request to this endpoint will create a new token |
The url part that says static-form
can be changed and comes from the config key static-form.path
The response for creating a token would be the following JSON with a 201 status:
- [ ] Make a plugin UI, just deciding on if it should be in package or a separate snippet.
Use the Middleware
To use the middleware, you can define a route using the config file, I do suggest that you use the API endpoint, this is as it is stateless and also would not require the CSRF token.
Submitting Forms
On your static site, you can have your contact form. The way of handling the form is done using the API part of the hosting provider.
So for Vercel apps, you can create a new file under the api
directory.
For the API part of the code:
You can try a simple form layout for the frontend:
Testing
Testing is currently a work in progress, there are some :), I am manually testing it in an actual application to make sure it works though.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- ReeceM
- All Contributors
License
The MIT License (MIT). Please see License File for more information.