generated from guanguans/package-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
1,015 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,22 +3,26 @@ | |
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the guanguans/laravel-web-tinker. | ||
* This file is part of the guanguans/laravel-code-runner. | ||
* | ||
* (c) guanguans <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled. | ||
*/ | ||
|
||
use PhpCsFixer\Config; | ||
use PhpCsFixer\Finder; | ||
|
||
$header = <<<EOF | ||
This file is part of the guanguans/laravel-web-tinker. | ||
This file is part of the guanguans/laravel-code-runner. | ||
(c) guanguans <[email protected]> | ||
This source file is subject to the MIT license that is bundled. | ||
EOF; | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
/** @noinspection PhpParamsInspection */ | ||
$finder = Finder::create() | ||
->in([ | ||
__DIR__.'/config', | ||
__DIR__.'/routes', | ||
|
@@ -46,7 +50,7 @@ | |
->ignoreDotFiles(true) | ||
->ignoreVCS(true); | ||
|
||
return (new PhpCsFixer\Config()) | ||
return (new Config()) | ||
->setRules([ | ||
'@DoctrineAnnotation' => true, | ||
'@PHP80Migration:risky' => true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
# Changelog | ||
|
||
All notable changes to `guanguans/laravel-web-tinker` will be documented in this file. | ||
All notable changes to `guanguans/laravel-code-runner` will be documented in this file. | ||
|
||
## 1.0.0 - 202X-XX-XX | ||
|
||
- Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,75 @@ | ||
# package-skeleton | ||
# laravel-code-runner | ||
|
||
[简体中文](README-zh_CN.md) | [ENGLISH](README.md) | ||
[ENGLISH](README.md) | [简体中文](README-zh_CN.md) | ||
|
||
> 一个 PHP 软件包模板存储库。- A PHP package template repository. | ||
> Run the code in the browser. - 在浏览器中运行代码。 | ||
[![tests](https://github.com/guanguans/laravel-web-tinker/workflows/tests/badge.svg)](https://github.com/guanguans/laravel-web-tinker/actions) | ||
[![check & fix styling](https://github.com/guanguans/laravel-web-tinker/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/guanguans/laravel-web-tinker/actions) | ||
[![codecov](https://codecov.io/gh/guanguans/laravel-web-tinker/branch/main/graph/badge.svg?token=URGFAWS6S4)](https://codecov.io/gh/guanguans/laravel-web-tinker) | ||
[![Latest Stable Version](https://poser.pugx.org/guanguans/laravel-web-tinker/v)](//packagist.org/packages/guanguans/laravel-web-tinker) | ||
[![Total Downloads](https://poser.pugx.org/guanguans/laravel-web-tinker/downloads)](//packagist.org/packages/guanguans/laravel-web-tinker) | ||
[![License](https://poser.pugx.org/guanguans/laravel-web-tinker/license)](//packagist.org/packages/guanguans/laravel-web-tinker) | ||
![GitHub repo size](https://img.shields.io/github/repo-size/guanguans/laravel-web-tinker) | ||
![GitHub release (latest by date)](https://img.shields.io/github/v/release/guanguans/laravel-web-tinker) | ||
|
||
## 功能 | ||
|
||
* 功能 | ||
[![tests](https://github.com/guanguans/laravel-code-runner/workflows/tests/badge.svg)](https://github.com/guanguans/laravel-code-runner/actions) | ||
[![check & fix styling](https://github.com/guanguans/laravel-code-runner/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/guanguans/laravel-code-runner/actions) | ||
[![codecov](https://codecov.io/gh/guanguans/laravel-code-runner/branch/main/graph/badge.svg?token=URGFAWS6S4)](https://codecov.io/gh/guanguans/laravel-code-runner) | ||
[![Latest Stable Version](https://poser.pugx.org/guanguans/laravel-code-runner/v)](//packagist.org/packages/guanguans/laravel-code-runner) | ||
[![Total Downloads](https://poser.pugx.org/guanguans/laravel-code-runner/downloads)](//packagist.org/packages/guanguans/laravel-code-runner) | ||
[![License](https://poser.pugx.org/guanguans/laravel-code-runner/license)](//packagist.org/packages/guanguans/laravel-code-runner) | ||
![GitHub repo size](https://img.shields.io/github/repo-size/guanguans/laravel-code-runner) | ||
![GitHub release (latest by date)](https://img.shields.io/github/v/release/guanguans/laravel-code-runner) | ||
|
||
## 环境要求 | ||
|
||
* PHP >= 7.4 | ||
* Laravel >= 7.0 | ||
|
||
## 安装 | ||
|
||
通过 Composer 安装该软件包。 | ||
|
||
```bash | ||
$ composer require guanguans/laravel-code-runner --prefer-dist -vvv | ||
``` | ||
|
||
运行此命令来发布资源文件。 | ||
|
||
```bash | ||
$ php artisan code-runner:install | ||
``` | ||
|
||
发布配置文件(可选的)。 | ||
|
||
```bash | ||
$ composer require guanguans/laravel-web-tinker --prefer-dist -vvv | ||
$ php artisan vendor:publish --provider="Guanguans\LaravelCodeRunner\WebTinkerServiceProvider" --tag="code-runner-config" | ||
``` | ||
|
||
## 使用 | ||
|
||
默认情况下,此包仅在本地环境中运行。 | ||
|
||
访问 `/code-runner` 查看页面。 | ||
|
||
![](docs/usage.png) | ||
|
||
### Authorization | ||
|
||
如果您想在另一个环境中运行它(我们不建议这样做),您必须执行两个步骤。 | ||
|
||
1. 您必须将 `code-runner` 配置文件中的 `enabled` 值设置为 `true`。 | ||
|
||
2. 您必须注册一个 `view-code-runner` 的 `ability`。最好在 Laravel 附带的 `AuthServiceProvider` 中。 | ||
|
||
```php | ||
use Illuminate\Contracts\Auth\Authenticatable; | ||
|
||
public function boot() | ||
{ | ||
$this->registerPolicies(); | ||
|
||
Gate::define('view-code-runner', function (?Authenticatable $user = null) { | ||
// 如果允许访问 web tinker,则返回 true。这是一个例子: | ||
return $user && in_array($user->email, [ | ||
'[email protected]', | ||
]); | ||
}); | ||
} | ||
``` | ||
|
||
## 测试 | ||
|
||
```bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,75 @@ | ||
# laravel-web-tinker | ||
# laravel-code-runner | ||
|
||
[简体中文](README-zh_CN.md) | [ENGLISH](README.md) | ||
[ENGLISH](README.md) | [简体中文](README-zh_CN.md) | ||
|
||
> A PHP package template repository. - 一个 PHP 软件包模板存储库。 | ||
> Run the code in the browser. - 在浏览器中运行代码。 | ||
[![tests](https://github.com/guanguans/laravel-web-tinker/workflows/tests/badge.svg)](https://github.com/guanguans/laravel-web-tinker/actions) | ||
[![check & fix styling](https://github.com/guanguans/laravel-web-tinker/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/guanguans/laravel-web-tinker/actions) | ||
[![codecov](https://codecov.io/gh/guanguans/laravel-web-tinker/branch/main/graph/badge.svg?token=URGFAWS6S4)](https://codecov.io/gh/guanguans/laravel-web-tinker) | ||
[![Latest Stable Version](https://poser.pugx.org/guanguans/laravel-web-tinker/v)](//packagist.org/packages/guanguans/laravel-web-tinker) | ||
[![Total Downloads](https://poser.pugx.org/guanguans/laravel-web-tinker/downloads)](//packagist.org/packages/guanguans/laravel-web-tinker) | ||
[![License](https://poser.pugx.org/guanguans/laravel-web-tinker/license)](//packagist.org/packages/guanguans/laravel-web-tinker) | ||
![GitHub repo size](https://img.shields.io/github/repo-size/guanguans/laravel-web-tinker) | ||
![GitHub release (latest by date)](https://img.shields.io/github/v/release/guanguans/laravel-web-tinker) | ||
|
||
## Features | ||
|
||
* Feature | ||
[![tests](https://github.com/guanguans/laravel-code-runner/workflows/tests/badge.svg)](https://github.com/guanguans/laravel-code-runner/actions) | ||
[![check & fix styling](https://github.com/guanguans/laravel-code-runner/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/guanguans/laravel-code-runner/actions) | ||
[![codecov](https://codecov.io/gh/guanguans/laravel-code-runner/branch/main/graph/badge.svg?token=URGFAWS6S4)](https://codecov.io/gh/guanguans/laravel-code-runner) | ||
[![Latest Stable Version](https://poser.pugx.org/guanguans/laravel-code-runner/v)](//packagist.org/packages/guanguans/laravel-code-runner) | ||
[![Total Downloads](https://poser.pugx.org/guanguans/laravel-code-runner/downloads)](//packagist.org/packages/guanguans/laravel-code-runner) | ||
[![License](https://poser.pugx.org/guanguans/laravel-code-runner/license)](//packagist.org/packages/guanguans/laravel-code-runner) | ||
![GitHub repo size](https://img.shields.io/github/repo-size/guanguans/laravel-code-runner) | ||
![GitHub release (latest by date)](https://img.shields.io/github/v/release/guanguans/laravel-code-runner) | ||
|
||
## Requirement | ||
|
||
* PHP >= 7.4 | ||
* Laravel >= 7.0 | ||
|
||
## Installation | ||
|
||
You can install the package via composer. | ||
|
||
```bash | ||
$ composer require guanguans/laravel-code-runner --prefer-dist -vvv | ||
``` | ||
|
||
Next, you must publish the assets from this package by running this command. | ||
|
||
```bash | ||
$ php artisan code-runner:install | ||
``` | ||
|
||
Optionally, you can publish the config file of the package. | ||
|
||
```bash | ||
$ composer require guanguans/laravel-web-tinker --prefer-dist -vvv | ||
$ php artisan vendor:publish --provider="Guanguans\LaravelCodeRunner\WebTinkerServiceProvider" --tag="code-runner-config" | ||
``` | ||
|
||
## Usage | ||
|
||
![](docs/usage.png) | ||
|
||
By default this package will only run in a local environment. | ||
|
||
Visit `/code-runner` in your app to view page. | ||
|
||
### Authorization | ||
|
||
Should you want to run this in another environment (we do not recommend this), there are two steps you must perform. | ||
|
||
1. You must set the `enabled` variable in the `code-runner` config file to `true`. | ||
|
||
2. You must register a `view-code-runner` ability. A good place to do this is in the `AuthServiceProvider` that ships with Laravel. | ||
|
||
```php | ||
use Illuminate\Contracts\Auth\Authenticatable; | ||
|
||
public function boot() | ||
{ | ||
$this->registerPolicies(); | ||
|
||
Gate::define('view-code-runner', function (?Authenticatable $user = null) { | ||
// Return true if access to web tinker is allowed. Here's an example: | ||
return $user && in_array($user->email, [ | ||
'[email protected]', | ||
]); | ||
}); | ||
} | ||
``` | ||
|
||
## Testing | ||
|
||
```bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the guanguans/laravel-web-tinker. | ||
* This file is part of the guanguans/laravel-code-runner. | ||
* | ||
* (c) guanguans <[email protected]> | ||
* | ||
|
@@ -10,4 +10,7 @@ | |
|
||
namespace { | ||
|
||
class CodeRunner extends \Guanguans\LaravelCodeRunner\Facades\CodeRunner | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.