1. Go to this page and download the library: Download goaop/goaop-laravel-bridge 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/ */
// bootstrap/app.php
// After `$app` is created
$app->register(\Go\Laravel\GoAopBridge\GoAopServiceProvider::class);
// bootstrap/app.php
// After `$app` is created
$app->configure('go_aop');
// config/go_aop.php
return [
/*
|--------------------------------------------------------------------------
| AOP Debug Mode
|--------------------------------------------------------------------------
|
| When AOP is in debug mode, then breakpoints in the original source code
| will work. Also engine will refresh cache files if the original files were
| changed.
| For production mode, no extra filemtime checks and better integration with opcache
|
*/
'debug' => env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application root directory
|--------------------------------------------------------------------------
|
| AOP will be applied only to the files in this directory, change it to app_path()
| if needed
*/
'appDir' => base_path(),
/*
|--------------------------------------------------------------------------
| AOP cache directory
|--------------------------------------------------------------------------
|
| AOP engine will put all transformed files and caches in that directory
*/
'cacheDir' => storage_path('app/aspect'),
/*
|--------------------------------------------------------------------------
| Cache file mode
|--------------------------------------------------------------------------
|
| If configured then will be used as cache file mode for chmod.
| WARNING! Use only integers here, not a string, e.g. 0770 instead of '0770'
*/
'cacheFileMode' => null,
/*
|--------------------------------------------------------------------------
| Controls miscellaneous features of AOP engine
|--------------------------------------------------------------------------
|
| See \Go\Aop\Features enumeration for bit mask
*/
'features' => 0,
/*
|--------------------------------------------------------------------------
| White list of directories
|--------------------------------------------------------------------------
|
| AOP will check this list to apply an AOP to selected directories only,
| leave it empty if you want AOP to be applied to all files in the appDir
*/
'
namespace App\Aspect;
use Go\Aop\Aspect;
use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Annotation\Before;
use Psr\Log\LoggerInterface;
/**
* Application logging aspect
*/
class LoggingAspect implements Aspect
{
/**
* @var LoggerInterface
*/
private $logger;
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* Writes a log info before method execution
*
* @param MethodInvocation $invocation
* @Before("execution(public **->*(*))")
*/
public function beforeMethod(MethodInvocation $invocation)
{
$this->logger->info($invocation, $invocation->getArguments());
}
}
namespace App\Providers;
use App\Aspect\LoggingAspect;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use Psr\Log\LoggerInterface;
class AopServiceProvider extends ServiceProvider
{
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->singleton(LoggingAspect::class, function (Application $app) {
return new LoggingAspect($app->make(LoggerInterface::class));
});
$this->app->tag([LoggingAspect::class], 'goaop.aspect');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.