PHP code example of kareem22t / structure-my-module
1. Go to this page and download the library: Download kareem22t/structure-my-module library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Example for RegisterUserRequest.php
public function rules(): array
{
return [
'name' => '|min:8|confirmed',
];
}
// Example for UpdateUserRequest.php
public function rules(): array
{
return [
'name' => 'sometimes|string|max:255',
'email' => 'sometimes|string|email|max:255|unique:users,email,' . auth()->id(),
'password' => 'sometimes|string|min:8|confirmed',
];
}
// app/Models/User.php
use Laravel\Sanctum\HasApiTokens; // For auth-sanctum type
class User extends Authenticatable
{
use HasApiTokens; // For auth-sanctum type
protected $fillable = [
'name',
'email',
'password',
];
protected $hidden = [
'password',
'remember_token',
];
}
bash
php artisan install:api
bash
php artisan migrate
bash
php artisan make:module User auth-mvc
bash
php artisan make:module User auth-sanctum
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.