-
Notifications
You must be signed in to change notification settings - Fork 5
/
console.php
44 lines (34 loc) · 1.36 KB
/
console.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* console application
* console.php
* @usage " php console.php [arguments] "
*/
use MarkMe\App;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\Output;
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
require __DIR__ . '/vendor/autoload.php';
$app = new App(array('debug' => true));
$console = $app['console'];
/** @var Application $console */
# register doctrine orm commands
$app['orm.console.boot_commands']();
/** encode a password with the application encoder */
$console->register('password:encode')
->setDescription('encode a password with a salt')
->addArgument('password', InputArgument::REQUIRED, 'the password to encode')
->addArgument('salt', InputArgument::REQUIRED, 'the password salt')
->setCode(function (Input $input, Output $output) use ($app) {
$digest = $app['security.encoder.digest'];
/** @var MessageDigestPasswordEncoder $digest */
$encodedPassword = $digest->encodePassword($input->getArgument('password'), $input->getArgument(('salt')));
$output->writeln("The encoded password is : ");
$output->writeln($encodedPassword);
exit(0);
});
$app->boot();
$app->flush();
$console->run();