Skip to content

Commit

Permalink
Merge pull request #3 from ristekusdi/console-command
Browse files Browse the repository at this point in the history
Console command
  • Loading branch information
kresnasatya authored Aug 9, 2022
2 parents 5b695cb + 87e82e1 commit 3a43b5d
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
19 changes: 19 additions & 0 deletions bin/sso
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env php
<?php

$root = dirname(__DIR__);

if (! is_file(sprintf('%s/vendor/autoload.php', $root))) {
$root = dirname(__DIR__, 4);
}

require sprintf('%s/vendor/autoload.php', $root);

use RistekUSDI\SSO\Commands\Copy;
use Symfony\Component\Console\Application;

$application = new Application();

$application->add(new Copy());

$application->run();
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
"php": "^7.2",
"illuminate/contracts": "^7.0",
"guzzlehttp/guzzle": "^7.4.5",
"vlucas/phpdotenv": "^5.4"
"vlucas/phpdotenv": "^5.4",
"symfony/console": "^5.4",
"illuminate/filesystem": "^7.30"
},
"bin": [
"bin/sso"
],
"license": "MIT",
"authors": [
{
Expand Down
39 changes: 39 additions & 0 deletions src/Commands/Copy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace RistekUSDI\SSO\Commands;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Illuminate\Filesystem\Filesystem;

class Copy extends Command
{
/**
* The name of the command (the part after "bin/sso").
*
* @var string
*/
protected static $defaultName = 'copy:ci3';

/**
* The command description shown when running "php bin/sso list".
*
* @var string
*/
protected static $defaultDescription = 'Copy SSO files for CodeIgniter 3.x!';

/**
* Execute the command
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int 0 if everything went fine, or an exit code.
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
(new Filesystem)->copyDirectory(__DIR__.'/../../stubs/ci3', 'application');
$output->writeln('Copy success!');
return Command::SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use RistekUSDI\SSO\Auth\Guard\WebGuard;
use RistekUSDI\SSO\Auth\AccessToken;

class Webauth extends CI_Controller {
class Netauth extends CI_Controller {

public function __construct()
{
Expand Down

0 comments on commit 3a43b5d

Please sign in to comment.