1. Go to this page and download the library: Download tenjuu99/wp-resta 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/ */
// src/Lib/Foo.php
namespace MyREST\Lib;
class Foo
{
private Bar $bar;
public function __construct(Bar $bar)
{
$this->bar = $bar;
}
public function getBarString(): string
{
return $this->bar->get();
}
}
// src/Lib/Bar.php
namespace MyREST\Lib;
class Bar
{
public function get(): string
{
return 'bar';
}
}
// src/Routes/Sample.php
namespace MyREST\Routes;
use MyREST\Lib\Foo;
class Sample extends AbstractRoute
{
private Foo $foo;
public function __construct(Foo $foo)
{
$this->foo = $foo;
}
public function callback()
{
return $this->foo->getBarString();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.