auto-api / auto-api-scwv
Laravel Auto API Single Controller Web View This package that you activate first to learn the secrets of the API, you can write one path and one controller then return the view to the web and from the same controller to restore and re-register the json. This package will write one source code for th
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
This package is auto-updated.
Last update: 2025-01-07 15:52:32 UTC
README
If no version is specified, it defaults to http://your-domain.com/api
.
Documention
Laravel Auto API Single Controller Web View
Overview
This package when that you installed that it can write one path and one controller then return the view to the web and from the same controller to restore and re-register the json. This package will write one source code for the web and the API at the same time, you do not need to write one source code for the web and another for the API and you don't need to write any route in file api.php and you don't need to write any custom controller for api. This package saves you from writing the source code because you will write single source code that works on the web and works on applications by one source code only
** installtion **
composer require auto-api/auto-api-scwv
** Settings **
if you want to set version for api
you can do this by .env
API_VERSION= v1.0
if you want to rename key api
in .env file you can rename key api
API_NAME= new_name
if you want to change auth type api
in .env file you can change auth
AUTH_API= auth:api
if you want to enable or disable clear cache route by default is true
in .env file you can do this
CLEAR_CACHE_ON_BOOT= false
if you want to gitignore any guard
it is simplly add this to auth.php file
'gitignore' => [
'api',
'sanctum',
'admin',
]
How To Use?
In controller
namespace App\Http\Controllers;
class ExampleController extends Controller
{
public function show()
{
return render('example'); // Use `render` instead of `view`
}
}
In blade File
href="{{ routeApi('about') }}
href="{{ routeApi('product', ['id' => $id]) }}
action="{{ routeApi('login') }}"
Custom Artisan Command Example
Create a new API request class with the command:
php artisan make:requestapi CreateUserRequest
This generates the file in the app/Http/Requests
directory, optimized for API validation.
Contribution
Feel free to contribute by submitting a pull request or reporting issues. All contributions are welcome and appreciated!
License
This package is open-sourced software licensed under the MIT license.