-
-
Notifications
You must be signed in to change notification settings - Fork 16
Description
I conducted an experiment with a clean project and nothing works.
curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
chmod a+x /usr/local/bin/symfony
symfony new aop 3.4
cd aop
composer require goaop/goaop-symfony-bundle
sed -i '/$bundles = \[/ a \ \ new Go\\Symfony\\GoAopBundle\\GoAopBundle(),' app/AppKernel.php
cat >> app/config/config.yml << 'END'
go_aop:
# This setting enables or disables an automatic AOP cache warming in the application.
# By default, cache_warmer is enabled (true), disable it only if you have serious issues with
# cache warming process.
cache_warmer: true
# This setting enables or disables workaround for weaving of Doctrine ORM entities. By default,
# it is disabled. If you are using Doctrine ORM and you are using AOP to weave Doctrine entities,
# enable this feature. For details about this known issue, see https://github.com/goaop/framework/issues/327
doctrine_support: false
# Additional settings for the Go! AOP kernel initialization
options:
# Debug mode for the AOP, enable it for debugging and switch off for production mode to have a
# better runtime performance for your application
debug: %kernel.debug%
# Application root directory, AOP will be applied ONLY to the files in this directory, by default it's
# src/ directory of your application.
app_dir: "%kernel.root_dir%/../src"
# AOP cache directory where all transformed files will be stored.
cache_dir: %kernel.cache_dir%/aspect
# Whitelist is array of directories where AOP should be enabled, leave it empty to process all files
include_paths: []
# Exclude list is array of directories where AOP should NOT be enabled, leave it empty to process all files
exclude_paths: []
# AOP container class name can be used for extending AOP engine or services adjustment
container_class: ~
# List of enabled features for AOP kernel, this allows to enable function interception, support for
# read-only file systems, etc. Each item should be a name of constant from the `Go\Aop\Features` class.
features: []
END
cat >> src/AppBundle/LoggingAspect.php << 'END'
<?php
namespace AppBundle;
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());
}
}
END
cat >> app/config/services.yml << 'END'
logging.aspect:
class: AppBundle\LoggingAspect
arguments: ["@logger"]
tags:
- { name: goaop.aspect }
END
composer dumpautoload
After request to app:
Fatal error: Uncaught Error: Class name must be a valid object or a string in /var/www/app/aop/vendor/goaop/framework/src/Core/AspectKernel.php on line 108
Make crutch bugfix:
sed -i 's/container_class: ~/container_class: Go\\Core\\GoAspectContainer/' app/config/config.yml
php bin/console cache:clear --env=prod
Opps:
PHP Fatal error: Uncaught Error: Class name must be a valid object or a string in /var/www/app/aop/vendor/goaop/framework/src/Core/AspectKernel.php:108
Hard lifehack:
rm -rf var/cache/prod/
New oops:
Fatal error: Cannot declare class AppBundle\Controller\DefaultController, because the name is already in use in /var/www/app/aop/src/AppBundle/Controller/DefaultController.php on line 0
php bin/console cache:warmup:aop --env=prod
Total 3 files to process.
[OK]: /var/www/app/aop/src/AppBundle/AppBundle.php
[OK]: /var/www/app/aop/src/AppBundle/Controller/DefaultController.php
[OK]: /var/www/app/aop/src/AppBundle/LoggingAspect.php
[DONE]: Total processed 3, 0 errors.
Any ideas? Any tips? Start guide?