1. Go to this page and download the library: Download emilianozublena/mikro-php 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/ */
namespace Mikro\Http\Controllers;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
class Home extends Controller
{
public function index(){
$response = $this->container->get('response');
return $response->create(
JsonResponse::class,
[
'message' => 'Some message'
],
Response::HTTP_OK
);
}
}
namespace Mikro\Http\Controllers;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
class Home extends Controller
{
public function index(){
$view = $this->container->get('view');
return $view->file('book')->render([
'hola' => 'chau'
])->getResponse();
}
}
namespace Mikro\Models;
use Illuminate\Database\Eloquent\Model;
class Book extends Model
{
protected $fillable = ['name', 'author', 'shelf_id'];
protected $with = ['shelf'];
}