PHP code example of thiagocordeiro / laravel-serializer
1. Go to this page and download the library: Download thiagocordeiro/laravel-serializer 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/ */
thiagocordeiro / laravel-serializer example snippets
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Illuminate\Routing\Router;
use LaravelSerializer\Framework\Routing\SerializerRouter;
class Kernel extends HttpKernel
{
public function __construct(Application $app, Router $router)
{
parent::__construct($app, SerializerRouter::from($router));
}
...
}
return [
App\MyObject::class => [], //
];
namespace App;
class Order
{
private int $customerId;
private Address $delivery;
private DateTime $placedAt;
/** @var Product[] */
private array $products;
public function __construct(int $customerId, Address $delivery, DateTime $placedAt, Product ...$products)
{
$this->customerId = $customerId;
$this->delivery = $delivery;
$this->placedAt = $placedAt;
$this->products = $products;
}
public function getCustomerId(): int
{
return $this->customerId;
}
public function getDelivery(): Address
{
return $this->delivery;
}
public function getPlacedAt(): DateTime
{
return $this->placedAt;
}
/**
* @return Product[]
*/
public function getProducts(): array
{
return $this->products;
}
}
use App\Order;
return [
...
Order::class => [],
];
use App\Order;
Route::post('/', function (Order $create) {
...
});
Route::get('/', function (): Order {
return new Order(...);
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.