1. Go to this page and download the library: Download bear/devtools 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/ */
bear / devtools example snippets
use BEAR\Dev\Halo\HaloModule;
use Ray\Di\AbstractModule;
class DevModule extends AbstractModule
{
protected function configure(): void
{
$this->install(new HaloModule($this));
}
}
use BEAR\Dev\Http\HttpResource;
// Start the built-in server and create an HTTP client.
// The third argument is the log destination and is optional
// (defaults to 'php://stderr'):
// - 'php://stderr' : write logs to STDERR (default)
// - '/path/to/file.log' : write every request to a single file
// - '/path/to/log' : a directory; one '<test-name>.log' per test method
$resource = new HttpResource('127.0.0.1:8080', '/path/to/public/index.php', __DIR__ . '/log');
// Make HTTP requests
$ro = $resource->get('/users');
assert($ro->code === 200);
$ro = $resource->post('/users', ['name' => 'John', 'email' => '[email protected]']);
assert($ro->code === 201);
use BEAR\Dev\Http\AbstractWorkflowTest;
use BEAR\Resource\ResourceInterface;
use BEAR\Resource\ResourceObject;
use MyVendor\MyProject\Injector;
use function assert;
class WorkflowTest extends AbstractWorkflowTest
{
protected function newResource(): ResourceInterface
{
$resource = Injector::getInstance('app')->getInstance(ResourceInterface::class);
assert($resource instanceof ResourceInterface);
return $resource;
}
public function testIndex(): ResourceObject
{
$index = $this->resource->get('/index');
$this->assertSame(200, $index->code);
return $index;
}
/** @depends testIndex */
public function testNext(ResourceObject $response): ResourceObject
{
return $this->follow($response, 'next');
}
}
use BEAR\Dev\Http\HttpResource;
use BEAR\Resource\ResourceInterface;
use MyVendor\MyProject\Hypermedia\WorkflowTest as Workflow;
class WorkflowTest extends Workflow
{
protected function newResource(): ResourceInterface
{
return new HttpResource('127.0.0.1:8088', __DIR__ . '/index.php', __DIR__ . '/log');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.