Versioning.php
Go to the documentation of this file.
1 <?php
2 
3 namespace App\Console\Commands;
4 
6 
8 
9 class Versioning extends Command {
10 
16  protected $name = 'versioning:update';
17 
23  protected $description = 'Generate and update app\'s version via git.';
24 
30  public function __construct()
31  {
32  parent::__construct();
33  }
34 
40  public function fire()
41  {
42  // Path to the file containing your version
43  // This will be overwritten everything you commit a message
44  $versionFile = app_path().'/config/version.php';
45 
46  // The git's output
47  // get the argument passed in the git command
48  $hash_version = $this->argument('app_version');
49 
50  // discard the commit hash
51  $version = explode('-', $hash_version);
52  $realVersion = $version[0] . '-' . $version[1];
53 
54  // save the version array to a variable
55  $array = var_export(array('app_version' => $realVersion,'hash_version' => $hash_version), true);
56 
57 
58  // Construct our file content
59  $content = <<<CON
60 <?php
61 return $array;
62 CON;
63 
64  // And finally write the file and output the current version
65  \File::put($versionFile, $content);
66  $this->line('Setting version: '. \config('version.latest'));
67  }
68 
74  protected function getArguments()
75  {
76  return array(
77  array('app_version', InputArgument::REQUIRED, 'version number is required.'),
78  );
79  }
80 
86  protected function getOptions()
87  {
88  return array(
89  );
90  }
91 }
fire()
Execute the console command.
Definition: Versioning.php:40
getOptions()
Get the console command options.
Definition: Versioning.php:86
__construct()
Create a new command instance.
Definition: Versioning.php:30
getArguments()
Get the console command arguments.
Definition: Versioning.php:74