1. Go to this page and download the library: Download w2w/laravel-apie 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/ */
w2w / laravel-apie example snippets
namespace App\RestApi\ApiResources;
use W2w\Lib\Apie\Annotations\ApiResource;
use W2w\Lib\Apie\Plugins\Core\DataLayers\NullDataLayer;
/**
* @ApiResource(disabledMethods={"get"}, persistClass=NullDataLayer::class)
*/
class SumExample
{
private $one;
private $two;
public function __construct(float $one, float $two)
{
$this->one = $one;
$this->two = $two;
}
public function getOne(): float
{
return $this->one;
}
public function getTwo(): float
{
return $this->two;
}
public function getAddition(): float
{
return $this->one + $this->two;
}
public function getSubtraction(): float
{
return $this->one - $this->two;
}
public function getMultiplication(): float
{
return $this->one * $this->two;
}
public function getDivison(): ?float
{
// === and == can fail because of floating points....
if (abs($this->two) < 0.000001) {
return null;
}
return $this->one / $this->two;
}
}
//config/apie.php
use App\ApiResources\SumExample;
use W2w\Lib\Apie\Plugins\ApplicationInfo\ApiResources\ApplicationInfo;
use W2w\Lib\Apie\Plugins\StatusCheck\ApiResources\Status;
return [
'resources' => [ApplicationInfo::class, Status::class, SumExample::class]
];
//config/apie.php
use W2w\Lib\Apie\Core\Resources\ApiResourcesFromNamespace;
return [
'resources' => ApiResourcesFromNamespace::createApiResources('App\RestApi\ApiResources'),
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.