<?php namespace app\command; use app\api\controller\DyNotifyController; use app\server\DyApiService; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Test extends Command { protected static $defaultName = 'test'; protected static $defaultDescription = '测试用'; /** * @return void */ protected function configure() { // $this->addArgument('name', InputArgument::OPTIONAL, 'Name description'); } /** * @param InputInterface $input * @param OutputInterface $output * @return int */ protected function execute(InputInterface $input, OutputInterface $output): int { $encryptStr = (new DyApiService())->encrypt('这是一个测试', env('DY_APPSECRET')); $output->write('加密字符串:' . $encryptStr); $decryptStr = (new DyApiService())->decrypt($encryptStr, env('DY_APPSECRET')); $output->write('解密字符串:' . $decryptStr); return 0; } }