Coder Social home page Coder Social logo

laravel-aspect's Introduction

Laravel-Aspect

aspect-oriented programming Package for laravel framework

Build Status StyleCI

License Latest Version Total Downloads

This library is heavily inspired by the jcabi/jcabi-aspects.

usage

Laravel version Compatibility

Laravel Package
5.0.x 1.x
5.1.x 1.x
5.2.x 1.x
5.3.x 1.x
5.4.x 1.x
5.5.x 2.0.*
5.6.x 2.1.*
5.7.x 3.0.*
6.0.x 4.0
7.x 6.0
8.x 7.0
9.x 8.0
10.x 9.0

install

$ composer require ytake/laravel-aspect

Supported Auto-Discovery(^Laravel5.5)

for Laravel9

Laravel-Aspect Supported Laravel5.6

  "require": {
   "php": ">=7.1.3",
   "laravel/framework": "^5.7",
   "ytake/laravel-aspect": "^8.0.0"
 },

added serviceProvider

'providers' => [
    // added AspectServiceProvider 
    \Ytake\LaravelAspect\AspectServiceProvider::class,
    // added Artisan Command
    \Ytake\LaravelAspect\ConsoleServiceProvider::class,
]

for Lumen

Add App\Providers\LumenAspectServiceProvider to your bootstrap/app.php file.

$app->register(\App\Providers\LumenAspectServiceProvider::class);
$app->register(\Ytake\LaravelAspect\ConsoleServiceProvider::class);

publish aspect module class

$ php artisan ytake:aspect-module-publish

more command options [--help]

publish configure

  • basic
$ php artisan vendor:publish
  • use tag option
$ php artisan vendor:publish --tag=aspect
  • use provider
$ php artisan vendor:publish --provider="Ytake\LaravelAspect\AspectServiceProvider"

register aspect module

config/ytake-laravel-aop.php

        'modules' => [
            // append modules
            // \App\Modules\CacheableModule::class,
        ],

use classes property

namespace App\Modules;

use Ytake\LaravelAspect\Modules\CacheableModule as PackageCacheableModule;

/**
 * Class CacheableModule
 */
class CacheableModule extends PackageCacheableModule
{
    /** @var array */
    protected $classes = [
        \YourApplication\Services\SampleService::class
    ];
}

example

namespace YourApplication\Services;

use Ytake\LaravelAspect\Annotation\Cacheable;

class SampleService
{
    /**
     * @Cacheable(cacheName="testing1",key={"#id"})
     */
    public function action($id) 
    {
        return $this;
    }
}

notice

  • Must use a service container
  • Classes must be non-final
  • Methods must be public

for Lumen

override Ytake\LaravelAspect\AspectServiceProvider

use Ytake\LaravelAspect\AspectManager;
use Ytake\LaravelAspect\AnnotationManager;
use Ytake\LaravelAspect\AspectServiceProvider as AspectProvider;

/**
 * Class AspectServiceProvider
 */
final class AspectServiceProvider extends AspectProvider
{
    /**
     * {@inheritdoc}
     */
    public function register()
    {
        $this->app->configure('ytake-laravel-aop');
        $this->app->singleton('aspect.manager', function ($app) {
            $annotationConfiguration = new AnnotationConfiguration(
                $app['config']->get('ytake-laravel-aop.annotation')
            );
            $annotationConfiguration->ignoredAnnotations();
            // register annotation
            return new AspectManager($app);
        });
    }
}

bootstrap/app.php

$app->register(App\Providers\AspectServiceProvider::class);

if ($app->runningInConsole()) {
    $app->register(Ytake\LaravelAspect\ConsoleServiceProvider::class);
}

Cache Clear Command

$ php artisan ytake:aspect-clear-cache

PreCompile Command

$ php artisan ytake:aspect-compile

Annotations

@Transactional

for database transaction(illuminate/database)

you must use the TransactionalModule

  • option
params description
value (or array) database connection
expect expect exception
use Ytake\LaravelAspect\Annotation\Transactional;

/**
 * @Transactional("master")
 */
public function save(array $params)
{
    return $this->eloquent->save($params);
}

Multiple Transaction

use Ytake\LaravelAspect\Annotation\Transactional;

/**
 * @Transactional({"master", "second_master"})
 */
public function save(array $params)
{
    $this->eloquent->save($params);
    $this->query->save($params);
}

@Cacheable

for cache(illuminate/cache)

you must use the CacheableModule

  • option
params description
key cache key
cacheName cache name(merge cache key)
driver Accessing Cache Driver(store)
lifetime cache lifetime (default: 120min)
tags Storing Tagged Cache Items
negative(bool) for null value (default: false)
use Ytake\LaravelAspect\Annotation\Cacheable;

/**
 * @Cacheable(cacheName="testing1",key={"#id","#value"})
 * @param $id
 * @param $value
 * @return mixed
 */
public function namedMultipleKey($id, $value)
{
    return $id;
}

@CacheEvict

for cache(illuminate/cache) / remove cache

you must use the CacheEvictModule

  • option
params description
key cache key
cacheName cache name(merge cache key)
driver Accessing Cache Driver(store)
tags Storing Tagged Cache Items
allEntries flush(default:false)
use Ytake\LaravelAspect\Annotation\CacheEvict;

/**
 * @CacheEvict(cacheName="testing",tags={"testing1"},allEntries=true)
 * @return null
 */
public function removeCache()
{
    return null;
}

@CachePut

for cache(illuminate/cache) / cache put

you must use the CachePutModule

  • option
params description
key cache key
cacheName cache name(merge cache key)
driver Accessing Cache Driver(store)
lifetime cache lifetime (default: 120min)
tags Storing Tagged Cache Items
use Ytake\LaravelAspect\Annotation\CachePut;

/**
 * @CachePut(cacheName={"testing1"},tags="testing1")
 */
public function throwExceptionCache()
{
    return 'testing';
}

@Loggable / @LogExceptions

for logger(illuminate/log, monolog)

you must use the LoggableModule / LogExceptionsModule

  • option
params description
value log level (default: \Monolog\Logger::INFO) should Monolog Constants
skipResult method result output to log
name log name prefix(default: Loggable)
driver logger driver or channel name docs
use Ytake\LaravelAspect\Annotation\Loggable;

class AspectLoggable
{
    /**
     * @Loggable(driver="stack")
     * @param null $id
     * @return null
     */
    public function normalLog($id = null)
    {
        return $id;
    }
}

sample)

[2015-12-23 08:15:30] testing.INFO: Loggable:__Test\AspectLoggable.normalLog {"args":{"id":1},"result":1,"time":0.000259876251221}

About @LogExceptions

Also, take a look at @Loggable. This annotation does the same, but also logs non-exceptional situations.

use Ytake\LaravelAspect\Annotation\LogExceptions;

class AspectLoggable
{
    /**
     * @LogExceptions(driver="custom")
     * @param null $id
     * @return null
     */
    public function dispatchLogExceptions()
    {
        return $this->__toString();
    }
}

About @QueryLog

for database query logger(illuminate/log, monolog, illuminate/database)

use Ytake\LaravelAspect\Annotation\QueryLog;
use Illuminate\Database\ConnectionResolverInterface;

/**
 * Class AspectQueryLog
 */
class AspectQueryLog
{
    /** @var ConnectionResolverInterface */
    protected $db;

    /**
     * @param ConnectionResolverInterface $db
     */
    public function __construct(ConnectionResolverInterface $db)
    {
        $this->db = $db;
    }

    /**
     * @QueryLog(driver="custom")
     */
    public function multipleDatabaseAppendRecord()
    {
        $this->db->connection()->statement('CREATE TABLE tests (test varchar(255) NOT NULL)');
        $this->db->connection('testing_second')->statement('CREATE TABLE tests (test varchar(255) NOT NULL)');
        $this->db->connection()->table("tests")->insert(['test' => 'testing']);
        $this->db->connection('testing_second')->table("tests")->insert(['test' => 'testing second']);
    }
}
testing.INFO: QueryLog:AspectQueryLog.multipleDatabaseAppendRecord {"queries":[{"query":"CREATE TABLE tests (test varchar(255) NOT NULL)","bindings":[],"time":0.58,"connectionName":"testing"},{"query":"CREATE TABLE tests (test varchar(255) NOT NULL)","bindings":[],"time":0.31,"connectionName":"testing_second"} ...

@RetryOnFailure

Retry the method in case of exception.

you must use the RetryOnFailureModule.

  • option
params description
attempts (int) How many times to retry. (default: 0)
delay (int) Delay between attempts. (default: 0 / sleep(0) )
types (array) When to retry (in case of what exception types). (default: <\Exception::class> )
ignore (string) Exception types to ignore. (default: \Exception )
use Ytake\LaravelAspect\Annotation\RetryOnFailure;

class ExampleRetryOnFailure
{
    /** @var int */
    public $counter = 0;

    /**
     * @RetryOnFailure(
     *     types={
     *         LogicException::class,
     *     },
     *     attempts=3,
     *     ignore=Exception::class
     * )
     */
    public function ignoreException()
    {
        $this->counter += 1;
        throw new \Exception;
    }
}

@MessageDriven

Annotation for a Message Queue(illuminate/queue. illuminate/bus).

you must use the MessageDrivenModule.

  • option
params description
value (Delayed) \Ytake\LaravelAspect\Annotation\LazyQueue or \Ytake\LaravelAspect\Annotation\EagerQueue (default: EagerQueue)
onQueue (string) To specify the queue. (default: null) )
mappedName (string) queue connection. (default: null/ default queue driver)
use Ytake\LaravelAspect\Annotation\EagerQueue;
use Ytake\LaravelAspect\Annotation\LazyQueue;
use Ytake\LaravelAspect\Annotation\Loggable;
use Ytake\LaravelAspect\Annotation\MessageDriven;

/**
 * Class AspectMessageDriven
 */
class AspectMessageDriven
{
    /**
     * @Loggable
     * @MessageDriven(
     *     @LazyQueue(3),
     *     onQueue="message"
     * )
     * @return void
     */
    public function exec($param)
    {
        echo $param;
    }

    /**
     * @MessageDriven(
     *     @EagerQueue
     * )
     * @param string $message
     */
    public function eagerExec($message)
    {
        $this->logWith($message);
    }

    /**
     * @Loggable(name="Queued")
     * @param string $message
     *
     * @return string
     */
    public function logWith($message)
    {
        return "Hello $message";
    }
}

LazyQueue

Handle Class Ytake\LaravelAspect\Queue\LazyMessage

EagerQueue

Handle Class Ytake\LaravelAspect\Queue\EagerMessage

Ignore Annotations

use config/ytake-laravel-aspect.php file

default: LaravelCollective/annotations

    'annotation' => [
        'ignores' => [
            // global Ignored Annotations
            'Hears',
            'Get',
            'Post',
            'Put',
            'Patch',
            'Options',
            'Delete',
            'Any',
            'Middleware',
            'Resource',
            'Controller'
        ],
    ],

Append Custom Annotations

    'annotation' => [
        'ignores' => [
            // global Ignored Annotations
            'Hears',
            'Get',
            'Post',
            'Put',
            'Patch',
            'Options',
            'Delete',
            'Any',
            'Middleware',
            'Resource',
            'Controller'
        ],
        'custom' => [
            \Acme\Annotations\Transactional::class
            // etc...
        ]
    ],

for testing

use none driver

<env name="ASPECT_DRIVER" value="none"/>

laravel-aspect's People

Contributors

4n70w4 avatar akitotsukahara avatar hohoangtung avatar izayoi256 avatar scrutinizer-auto-fixer avatar yamotuki avatar ytake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-aspect's Issues

Don't declare Annotation classes as final

Case: need extend annotations, for example, redeclare dafault values.

Currently I get error: Class may not inherit from final class.

@ytake are there objective reasons to make classes as final?

I propose to remove final everywhere.

Feature/Question: Mock Interceptors

Hi! I want to check interceptors calls in unit test.

Test fragment:

$interceptor = \Mockery::mock(LogExceptionsInterceptor::class);
$this->instance(LogExceptionsInterceptor::class, $interceptor);

In configure of LogExceptionsPointCut I replace:

$interceptor = new LogExceptionsInterceptor;

to

$interceptor = $app[LogExceptionsInterceptor::class];

But currently calls PointCut's configure before run tests and can't rebind to mock.

Any ideas on how to test it?

Composer validate failed with PHP 8.0

I used to Docker to set up and run composer validate
There are some issues

1. symfony/console version

image

2. illuminate/encryption version

image

My Dockerfile is below

FROM php:8.0-apache
RUN apt-get update && apt-get upgrade -y
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

How to debug and troubleshooting?

Hi! I use Laravel 5.8 and I did everything according to your instructions, but nothing works.

How do I better identify and fix the problem?

I see file storage/framework/aop/compile/App_Integrations_Client_M1mYMgA.php

All code simplified and obsfuscated.

<?php

use Ytake\LaravelAspect\Annotation\Cacheable;

class App_IntegrationsClient_M1mYMgA extends App\Integrations\Client implements Ray\Aop\WeavedInterface
{
    private $isIntercepting = true;
    public $bind;
    public $methodAnnotations = 'a:1:{s:23:"getOrganization";a:1:{i:0;O:40:"Ytake\\LaravelAspect\\Annotation\\Cacheable":7:{s:3:"key";a:1:{i:0;s:4:"#token";}s:9:"cacheName";s:8:"testing1";s:6:"driver";N;s:8:"lifetime";i:120;s:4:"tags";a:0:{}s:8:"negative";b:0;s:5:"value";N;}}}';
    public $classAnnotations = 'a:0:{}';
    /**
     * @Cacheable(cacheName="testing1",key={"#token"})
     */
    function getOrganization(string $token) {
        if ($this->isIntercepting === false) {
            $this->isIntercepting = true;
            return parent::getOrganization($token);
        }
        $this->isIntercepting = false;
        // invoke interceptor
        $result = (new \Ray\Aop\ReflectiveMethodInvocation($this, __FUNCTION__, [$token], $this->bindings[__FUNCTION__]))->proceed();
        $this->isIntercepting = true;
        return $result;
    }
}

Also my Service Provider:

class ClientServiceProvider extends ServiceProvider {

    protected $defer = true;


    public function register() {

        $this->app->bind(Client::class);

        $this->app->when(Client::class)
            ->needs('$config')
            ->give(config('client') );
    }


    public function provides() {
        return [Client::class];
    }

}

Client class:

class Client {

    /**
     * @Cacheable(cacheName="testing1",key={"#token"})
     */
    public function getOrganization(string $token) {
        return null;
    }

Job:

class Send implements ShouldQueue {
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;


    public function handle(Client $client) {
       // expected App_IntegrationsClient_M1mYMgA instance instead Client
    }

I expected App_IntegrationsClient_M1mYMgA instance instead Client. So it should work? But but I receive the original Client.

What do I need to check that everything works as it should?

php artisan debug:container
from https://github.com/bernardosecades/laravel-debug-container

show only original Client.

php -v

PHP 7.3.4 (cli) (built: Apr  2 2019 13:48:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.4, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.7.1, Copyright (c) 2002-2019, by Derick Rethans

Laravel9 support

Is there plan to support Laravel 9?

When updating to Laravel 9, there was a problem due to this library's illuminate/console being ^8.0.
When upgrading symfony/console to ^6.0, the following problems occurred.

  • illuminate/console[v8.18.1, ... , v8.73.2] require symfony/console ^5.1.4
  • ytake/laravel-aspect 7.0.0 requires illuminate/console ^8.0

After update to 5.0 ErrorException : Undefined index: force_compile

composer require ytake/laravel-aspect:5.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
    1/1:        https://codeload.github.com/ytake/Laravel-Aspect/legacy.zip/b949ca4501fa0f03e42e8a8d13c6bfbc637856e6
    Finished: success: 1, skipped: 0, failure: 0, total: 1
Package operations: 0 installs, 1 update, 0 removals
  - Updating ytake/laravel-aspect (4.0.0 => 5.0.0): Loading from cache
Writing lock file
Generating optimized autoload files
Processing patches configuration
Nothing to patch
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   ErrorException  : Undefined index: force_compile

  at /var/www/app/vendor/ytake/laravel-aspect/src/RayAspectKernel.php:148
    144|      */
    145|     protected function makeCompileDir()
    146|     {
    147|         $this->makeDirectories(strval($this->configure['compile_dir']), 0775);
  > 148|         $this->forceCompile = (bool)$this->configure['force_compile'];
    149|     }
    150|
    151|     /**
    152|      * make aspect cache directory

  Exception trace:

  1   Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Undefined index: force_compile", "/var/www/app/vendor/ytake/laravel-aspect/src/RayAspectKernel.php", [])
      /var/www/app/vendor/ytake/laravel-aspect/src/RayAspectKernel.php:148

  2   Ytake\LaravelAspect\RayAspectKernel::makeCompileDir()
      /var/www/app/vendor/ytake/laravel-aspect/src/RayAspectKernel.php:84

  Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Installation failed, reverting ./composer.json to its original content.

@izayoi256 any ideas?

Every modules are not working.

I installed fully like how documentation to do.

and, no errors, but not working every modules even I re-installed for several times.

also installing it with Laravel 5.6 we got 'ikic/php-parser' dependency error.

Can I ask a question about Loggable

From Interceptor/LoggableInterceptor.php

        /** Monolog\Logger */
        if ($logger instanceof LogManager) {
            if (!is_null($annotation->driver)) {
                $logger = $logger->driver($annotation->driver);
            }
            $logger->addRecord($logFormat['level'], $logFormat['message'], $logFormat['context']);
        }

And from LogManager (https://github.com/illuminate/log/blob/master/LogManager.php)

    /**
     * Get a log channel instance.
     *
     * @param  string|null  $channel
     * @return \Psr\Log\LoggerInterface
     */
    public function channel($channel = null)
    {
        return $this->driver($channel);
    }

    /**
     * Get a log driver instance.
     *
     * @param  string|null  $driver
     * @return \Psr\Log\LoggerInterface
     */
    public function driver($driver = null)
    {
        return $this->get($this->parseDriver($driver));
    }

    /**
     * Attempt to get the log from the local cache.
     *
     * @param  string  $name
     * @param  array|null  $config
     * @return \Psr\Log\LoggerInterface
     */
    protected function get($name, ?array $config = null)
    {
        try {
            return $this->channels[$name] ?? with($this->resolve($name, $config), function ($logger) use ($name) {
                return $this->channels[$name] = $this->tap($name, new Logger($logger, $this->app['events']))->withContext($this->sharedContext);
            });
        } catch (Throwable $e) {
            return tap($this->createEmergencyLogger(), function ($logger) use ($e) {
                $logger->emergency('Unable to create configured logger. Using emergency logger.', [
                    'exception' => $e,
                ]);
            });
        }
    }

Because this is only "$this->channels", does not have "$this->drivers", so, As I understand. Loggable annotation' driver variable only supports channel name, does not support driver name.
Is this correct?
I'm sorry in advance if I'm wrong.

Feature/Question: Integrate with Mockery\Container

I have compiled wrapper for Repository class.

Via app(Repository::class) I get compiled wrapper.

But via \Mockery::mock(Repository::class) I get origin Repository class without compiled wrapper.

Workaround: \Mockery::mock(app(Repository::class))

But there is a problem with the human factor. People may forget to do this.

Any ideas how to get the compiled wrapper immediately through \Mockery::mock()?

Dependency error via Composer

I am running HHVM version 3.15 and when trying to install it via composer I get this error

composer require ytake/laravel-aspect
SlowTimer [6491ms] at curl: http://packagist.org/p/provider-2016-10%2472c8fad92b93566ed9953cc3844641e109d2f9472797e5c8b04c2bb19cf5df4a.json
Using version ^1.5 for ytake/laravel-aspect
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install ytake/laravel-aspect 1.5.1
    - Conclusion: remove nikic/php-parser v3.0.2
    - Installation request for ytake/laravel-aspect ^1.5 -> satisfiable by ytake/laravel-aspect[1.5.0, 1.5.1].
    - Conclusion: don't install nikic/php-parser v3.0.2
    - ytake/laravel-aspect 1.5.0 requires ray/aop ~2.0 -> satisfiable by ray/aop[2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.2.0, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.4.0, 2.4.1].
    - ray/aop 2.3.1 requires nikic/php-parser ~1.3||~2.0 -> satisfiable by nikic/php-parser[v1.3.0, v1.4.0, v1.4.1, v2.0.0, v2.0.1, v2.1.0, v2.1.1].
    - ray/aop 2.3.2 requires nikic/php-parser ~1.3||~2.0 -> satisfiable by nikic/php-parser[v1.3.0, v1.4.0, v1.4.1, v2.0.0, v2.0.1, v2.1.0, v2.1.1].
    - ray/aop 2.3.3 requires nikic/php-parser ~1.3||~2.0 -> satisfiable by nikic/php-parser[v1.3.0, v1.4.0, v1.4.1, v2.0.0, v2.0.1, v2.1.0, v2.1.1].
    - ray/aop 2.4.0 requires nikic/php-parser ~1.3||~2.0 -> satisfiable by nikic/php-parser[v1.3.0, v1.4.0, v1.4.1, v2.0.0, v2.0.1, v2.1.0, v2.1.1].
    - ray/aop 2.4.1 requires nikic/php-parser ~1.3||~2.0 -> satisfiable by nikic/php-parser[v1.3.0, v1.4.0, v1.4.1, v2.0.0, v2.0.1, v2.1.0, v2.1.1].
    - ray/aop 2.0.0 requires nikic/php-parser ~1.0 -> satisfiable by nikic/php-parser[v1.0.0, v1.0.1, v1.0.2, v1.1.0, v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.4.0, v1.4.1].
    - ray/aop 2.0.1 requires nikic/php-parser ~1.0 -> satisfiable by nikic/php-parser[v1.0.0, v1.0.1, v1.0.2, v1.1.0, v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.4.0, v1.4.1].
    - ray/aop 2.1.0 requires nikic/php-parser ~1.0 -> satisfiable by nikic/php-parser[v1.0.0, v1.0.1, v1.0.2, v1.1.0, v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.4.0, v1.4.1].
    - ray/aop 2.1.1 requires nikic/php-parser ~1.0 -> satisfiable by nikic/php-parser[v1.0.0, v1.0.1, v1.0.2, v1.1.0, v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.4.0, v1.4.1].
    - ray/aop 2.2.0 requires nikic/php-parser ~1.0 -> satisfiable by nikic/php-parser[v1.0.0, v1.0.1, v1.0.2, v1.1.0, v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.4.0, v1.4.1].
    - ray/aop 2.3.0 requires nikic/php-parser ~1.0 -> satisfiable by nikic/php-parser[v1.0.0, v1.0.1, v1.0.2, v1.1.0, v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.4.0, v1.4.1].
    - Can only install one of: nikic/php-parser[v1.2.0, v3.0.2].
    - Can only install one of: nikic/php-parser[v1.2.1, v3.0.2].
    - Can only install one of: nikic/php-parser[v1.2.2, v3.0.2].
    - Can only install one of: nikic/php-parser[v1.3.0, v3.0.2].
    - Can only install one of: nikic/php-parser[v1.4.0, v3.0.2].
    - Can only install one of: nikic/php-parser[v1.4.1, v3.0.2].
    - Can only install one of: nikic/php-parser[v2.0.0, v3.0.2].
    - Can only install one of: nikic/php-parser[v2.0.1, v3.0.2].
    - Can only install one of: nikic/php-parser[v2.1.0, v3.0.2].
    - Can only install one of: nikic/php-parser[v2.1.1, v3.0.2].
    - Can only install one of: nikic/php-parser[v1.0.0, v3.0.2].
    - Can only install one of: nikic/php-parser[v1.0.1, v3.0.2].
    - Can only install one of: nikic/php-parser[v1.0.2, v3.0.2].
    - Can only install one of: nikic/php-parser[v1.1.0, v3.0.2].
    - Installation request for nikic/php-parser (locked at v3.0.2) -> satisfiable by nikic/php-parser[v3.0.2].


Installation failed, reverting ./composer.json to its original content.

stub module class make command

  • パッケージで用意しているモジュールを利用する為のクラス生成コマンドを作成
  • モジュールごとの作成も可能に
  • プロジェクトのnamespaceを反映

Lumen - Error on Setting Up

I am using Lumen 5.6. When I run any commands or access any functions through Postman I get this error:

Class 'App\Providers\AnnotationConfiguration' not found

When I added this use Ytake\LaravelAspect\AnnotationConfiguration; in AspectServiceProvider.php, the above issue resolved but now I am getting this error.

Type error: Argument 1 passed to Ytake\LaravelAspect\AnnotationConfiguration::__construct() must be of the type array, null given, called in C:\Projects\cs415_api\app\Providers\AspectServiceProvider.php on line 22

I suspect that the following line in AspectServiceProvider returns null.

$app['config']->get('ytake-laravel-aop.annotation')

Any ideas on how to resolve this error?

No default values for config variables fail the installation process

When using cached config you don't have the config values required by the package
Then after you require the package the dump-autoload fail with:
Argument 1 passed to Ytake\LaravelAspect\AnnotationConfiguration::__construct() must be of the type array, null given, called in...
image

You need to add default values or to write in documentation to run php artisan config:clear before requiring the package

ASPECT_CACHEABLE=true don't work because\Ray\Aop\Compiler::compile compile and saved files every requests

        if (class_exists($aopClassName, false)) {

https://github.com/ray-di/Ray.Aop/blob/8dcf395c66c206a238ad1a609e984c01e773cdaa/src/Compiler.php#L79

class_exists ( string $class_name [, bool $autoload = TRUE ] ) : bool

This function checks whether or not the given class has been defined.

class_name
The class name. The name is matched in a case-insensitive manner.

autoload
Whether or not to call __autoload by default.

Because class_exists checks without autoload - every request recompiled all classes with AOP annotations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.