1. Go to this page and download the library: Download next/aop 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 App\aspects;
use Closure;
use Next\Aop\JoinPoint;
use Next\Aop\Contract\AspectInterface;
#[\Attribute(\Attribute::TARGET_METHOD)]
class Round implements AspectInterface
{
public function process(JoinPoint $joinPoint, Closure $next): mixed
{
echo 'before';
$result = $next($joinPoint);
echo 'after';
return $result;
}
}
namespace app\controller;
use App\Aop\Attribute\Inject;use App\aspects\Round;use support\Request;
class Index
{
#[Inject]
protected Request $request;
#[Round]
public function index()
{
echo '--controller--';
return response('hello webman');
}
}
namespace App\aspects;
use Closure;
use Next\Aop\Attribute\AspectConfig;
use Next\Aop\JoinPoint;
use Next\Aop\Contract\AspectInterface;
#[\Attribute(\Attribute::TARGET_METHOD)]
#[AspectConfig('BaconQrCode\Writer', 'writeFile')]
class Round implements AspectInterface
{
public function process(JoinPoint $joinPoint, Closure $next): mixed
{
echo 'before';
$result = $next($joinPoint);
echo 'after';
return $result;
}
}
php 8.2
开启passthru函数
shell
php start.php start
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.