AloWAMP source documentation
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • None
  • PHP
  • Setup
  • VersionSwitch

Classes

  • AbstractBinSetup
  • AbstractSetup
  • Apache
  • Memcache
  • MySQL
  • PHP
  • Redis
 1 <?php
 2 
 3    namespace Setup;
 4 
 5    use Downloader;
 6 
 7    /**
 8     * Abstract setup for binaries
 9     *
10     * @author Art <a.molcanovas@gmail.com>
11     */
12    abstract class AbstractBinSetup extends AbstractSetup {
13 
14       /**
15        * Download links
16        *
17        * @var array
18        */
19       protected $links;
20 
21       /**
22        * Version selected
23        *
24        * @var string
25        */
26       protected $version;
27 
28       /**
29        * Destination to unzip to
30        *
31        * @var string
32        */
33       protected $unzipped_destination;
34 
35       /**
36        * Prompts to download a version
37        *
38        * @author Art <a.molcanovas@gmail.com>
39        * @return AbstractBinSetup
40        */
41       protected function promptDownload() {
42          if(!empty($this->links)) {
43             $version_numbers = array_keys($this->links);
44             _echo('The following versions were found for download: ' . PHP_EOL . "\t"
45                   . implode(PHP_EOL . "\t", $version_numbers));
46 
47             $io = trim(\IO::readline('Which version would you like to download? Input N to abort'));
48 
49             if(!$io) {
50                $this->promptDownload();
51             } elseif($io == 'n') {
52                die('Aborting.');
53             } elseif(!isset($this->links[$io])) {
54                _echo('The version you selected is not available for download.');
55                $this->promptDownload();
56             } else {
57                _echo('Contacting download server...');
58                $this->version = $io;
59                $this->download();
60 
61                return $this;
62             }
63          } else {
64             die('Aborting.');
65          }
66 
67          return $this;
68       }
69 
70       /**
71        * Downloads a version
72        *
73        * @author Art <a.molcanovas@gmail.com>
74        * @return AbstractBinSetup
75        */
76       protected function download() {
77          $this->downloader = new Downloader($this->links[$this->version], $this->dest);
78 
79          if($this->downloader->download()) {
80             _echo('Download successful. Setting up version ' . $this->version);
81             sleep(1);
82          } else {
83             die('Download failed. Aborting setup.');
84          }
85 
86          return $this;
87       }
88    }
AloWAMP source documentation API documentation generated byApiGen 2.8.0