1. Go to this page and download the library: Download moeen-basra/photon 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/ */
moeen-basra / photon example snippets
use Illuminate\Routing\Controller as BaseController;
use MoeenBasra\Photon\Http\Controller as BaseController;
namespace App\Http\Controllers\Api\Auth;
use App\Features\Api\Auth\RegisterFeature;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use MoeenBasra\Photon\Http\Controller;
class AuthController extends Controller
{
public function __construct()
{
$this->middleware('auth:api', ['only' => ['me', 'logout']]);
}
public function register(Request $request): JsonResponse
{
return $this->serve(RegisterFeature::class, [
'data' => $request->validated(),
]);
}
}
namespace App\Features\Api\Auth;
use App\Operations\Auth\RegisterOperation;
use Illuminate\Http\JsonResponse;
use Photon\Actions\JsonResponseAction;
use MoeenBasra\Photon\Features\Feature;
final class RegisterFeature extends Feature
{
public function __construct(
readonly private array $input
){}
public function handle(): JsonResponse
{
$data = $this->run(RegisterOperation::class, [
'input' => $this->input
]);
return $this->run(new JsonResponseAction($data));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.