Skip to content

Nano and AOP #5035

Answered by huangdijia
leocavalcante asked this question in Q&A
Aug 19, 2022 · 4 comments · 2 replies
Discussion options

You must be logged in to vote

Example:

  1. Adds config/autoload/annotations.php
<?php
return [
    'scan' => [
        'paths' => [
            BASE_PATH . '/app',
        ],
    ],
];
  1. Adds ClassLoader::init() before AppFactory::create() in app.php
<?php

use Hyperf\Di\ClassLoader;
use Hyperf\Nano\Factory\AppFactory;

require_once __DIR__ . '/vendor/autoload.php';

define('BASE_PATH', __DIR__);
ClassLoader::init();

$app = AppFactory::create();

$app->run();
  1. Testing, make a command app/Command/FooCommand
<?php

namespace App\Command;

use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerInterface;
use Hyperf\Command\Annotation\Command;

#[Command()]
class FooCommand extends \Hyperf\Command\Command
{
    prote…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by leocavalcante
Comment options

You must be logged in to vote
1 reply
@huangdijia
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@leocavalcante
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants