1. Go to this page and download the library: Download chefhasteeth/pipeline 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/ */
chefhasteeth / pipeline example snippets
use Chefhasteeth\Pipeline\Pipeline;
class RegisterController
{
public function store(StoreRegistrationRequest $request)
{
return Pipeline::make()
->send($request->all())
->through([
RegisterUser::class,
AddMemberToTeam::class,
SendWelcomeEmail::class,
])
->then(fn ($data) => UserResource::make($data));
}
}
use Chefhasteeth\Pipeline\Pipable;
class UserDataObject
{
use Pipable;
public string $name;
public string $email;
public string $password;
// ...
}
class RegisterController
{
public function store(StoreRegistrationRequest $request)
{
return UserDataObject::fromRequest($request)
->pipeThrough([
RegisterUser::class,
AddMemberToTeam::class,
SendWelcomeEmail::class,
])
->then(fn ($data) => UserResource::make($data));
}
}