Skip to content

Commit

Permalink
Package update
Browse files Browse the repository at this point in the history
  • Loading branch information
chenos committed Feb 7, 2018
1 parent ce2d324 commit 483a2e8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 25 deletions.
28 changes: 8 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,29 @@ Access http://127.0.0.1:9999

```php
use Chenos\ExecJs\Context;
use Chenos\V8JsModuleLoader\ModuleLoader;

$context = new Context('PHP');

$context->getLoader()
->setEntryDir(__DIR__)
->setExtensions('.js', '.json')
->addVendorDir(__DIR__.'/node_modules')
->addOverride('vue', 'vue/dist/vue.runtime.common.js')
;
// or
$loader = new ModuleLoader();
$loader->setEntryDir(__DIR__)
->addVendorDir(__DIR__.'/node_modules')
->addOverride('vue', 'vue/dist/vue.runtime.common.js')
;
$context->setLoader($loader);

$context->eval(string $script);
$context->load(string $module);
$context->require($module, string|array $identifier);
$context->set(string $key, mixed $value, $global = false);
```

Vue Example (incomplete)

```php
use Chenos\ExecJs\Context;

$context = new Context();

$context->getLoader()
->setEntryDir(__DIR__)
->setExtensions('.js', '.json')
->addVendorDir(__DIR__.'/node_modules')
->addOverride('vue', 'vue/dist/vue.runtime.common.js')
;

$context->require('./renderToString.js', 'renderToString');
$context->require('./hello.js', 'hello');
$context->eval("renderToString(hello).then(print)");
```

## API

### eval
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "chenos/execjs",
"require": {
"chenos/v8js-module-loader": "^0.3.0"
"chenos/v8js-module-loader": "^0.4.0"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
Expand Down
3 changes: 1 addition & 2 deletions src/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
namespace Chenos\ExecJs;

use V8Js;
use Chenos\V8Js\ModuleLoader\ModuleLoader;
use Chenos\V8Js\ModuleLoader\FileSystemInterface;
use Chenos\V8JsModuleLoader\ModuleLoader;

class Context
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use V8Js;
use Chenos\ExecJs\Context;
use PHPUnit\Framework\TestCase;
use Chenos\V8Js\ModuleLoader\ModuleLoader;
use Chenos\V8JsModuleLoader\ModuleLoader;

class ContextTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Chenos\ExecJs\Tests;

class FileSystem extends \Chenos\V8Js\ModuleLoader\FileSystem
class FileSystem extends \Chenos\V8JsModuleLoader\FileSystem
{
protected $paths = [];

Expand Down

0 comments on commit 483a2e8

Please sign in to comment.