aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Command/InstallCommand.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Command/InstallCommand.php')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php56
1 files changed, 45 insertions, 11 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 2daf2dd8..f0738b91 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -40,7 +40,7 @@ class InstallCommand extends ContainerAwareCommand
40 { 40 {
41 $this 41 $this
42 ->setName('wallabag:install') 42 ->setName('wallabag:install')
43 ->setDescription('Wallabag installer.') 43 ->setDescription('wallabag installer.')
44 ->addOption( 44 ->addOption(
45 'reset', 45 'reset',
46 null, 46 null,
@@ -55,7 +55,7 @@ class InstallCommand extends ContainerAwareCommand
55 $this->defaultInput = $input; 55 $this->defaultInput = $input;
56 $this->defaultOutput = $output; 56 $this->defaultOutput = $output;
57 57
58 $output->writeln('<info>Installing Wallabag...</info>'); 58 $output->writeln('<info>Installing wallabag...</info>');
59 $output->writeln(''); 59 $output->writeln('');
60 60
61 $this 61 $this
@@ -65,7 +65,7 @@ class InstallCommand extends ContainerAwareCommand
65 ->setupConfig() 65 ->setupConfig()
66 ; 66 ;
67 67
68 $output->writeln('<info>Wallabag has been successfully installed.</info>'); 68 $output->writeln('<info>wallabag has been successfully installed.</info>');
69 $output->writeln('<comment>Just execute `php bin/console server:run --env=prod` for using wallabag: http://localhost:8000</comment>'); 69 $output->writeln('<comment>Just execute `php bin/console server:run --env=prod` for using wallabag: http://localhost:8000</comment>');
70 } 70 }
71 71
@@ -78,7 +78,7 @@ class InstallCommand extends ContainerAwareCommand
78 78
79 // testing if database driver exists 79 // testing if database driver exists
80 $fulfilled = true; 80 $fulfilled = true;
81 $label = '<comment>PDO Driver</comment>'; 81 $label = '<comment>PDO Driver (%s)</comment>';
82 $status = '<info>OK!</info>'; 82 $status = '<info>OK!</info>';
83 $help = ''; 83 $help = '';
84 84
@@ -88,7 +88,7 @@ class InstallCommand extends ContainerAwareCommand
88 $help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.'; 88 $help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.';
89 } 89 }
90 90
91 $rows[] = [$label, $status, $help]; 91 $rows[] = [sprintf($label, $this->getContainer()->getParameter('database_driver')), $status, $help];
92 92
93 // testing if connection to the database can be etablished 93 // testing if connection to the database can be etablished
94 $label = '<comment>Database connection</comment>'; 94 $label = '<comment>Database connection</comment>';
@@ -96,7 +96,8 @@ class InstallCommand extends ContainerAwareCommand
96 $help = ''; 96 $help = '';
97 97
98 try { 98 try {
99 $doctrineManager->getConnection()->connect(); 99 $conn = $this->getContainer()->get('doctrine')->getManager()->getConnection();
100 $conn->connect();
100 } catch (\Exception $e) { 101 } catch (\Exception $e) {
101 if (false === strpos($e->getMessage(), 'Unknown database') 102 if (false === strpos($e->getMessage(), 'Unknown database')
102 && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) { 103 && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) {
@@ -108,12 +109,25 @@ class InstallCommand extends ContainerAwareCommand
108 109
109 $rows[] = [$label, $status, $help]; 110 $rows[] = [$label, $status, $help];
110 111
111 // testing if PostgreSQL > 9.1 112 // check MySQL & PostgreSQL version
112 $label = '<comment>SGBD version</comment>'; 113 $label = '<comment>Database version</comment>';
113 $status = '<info>OK!</info>'; 114 $status = '<info>OK!</info>';
114 $help = ''; 115 $help = '';
115 116
116 if ('postgresql' === $doctrineManager->getConnection()->getSchemaManager()->getDatabasePlatform()->getName()) { 117 // now check if MySQL isn't too old to handle utf8mb4
118 if ($conn->isConnected() && 'mysql' === $conn->getDatabasePlatform()->getName()) {
119 $version = $conn->query('select version()')->fetchColumn();
120 $minimalVersion = '5.5.4';
121
122 if (false === version_compare($version, $minimalVersion, '>')) {
123 $fulfilled = false;
124 $status = '<error>ERROR!</error>';
125 $help = 'Your MySQL version ('.$version.') is too old, consider upgrading ('.$minimalVersion.'+).';
126 }
127 }
128
129 // testing if PostgreSQL > 9.1
130 if ($conn->isConnected() && 'postgresql' === $conn->getDatabasePlatform()->getName()) {
117 // return version should be like "PostgreSQL 9.5.4 on x86_64-apple-darwin15.6.0, compiled by Apple LLVM version 8.0.0 (clang-800.0.38), 64-bit" 131 // return version should be like "PostgreSQL 9.5.4 on x86_64-apple-darwin15.6.0, compiled by Apple LLVM version 8.0.0 (clang-800.0.38), 64-bit"
118 $version = $doctrineManager->getConnection()->query('SELECT version();')->fetchColumn(); 132 $version = $doctrineManager->getConnection()->query('SELECT version();')->fetchColumn();
119 133
@@ -152,7 +166,7 @@ class InstallCommand extends ContainerAwareCommand
152 throw new \RuntimeException('Some system requirements are not fulfilled. Please check output messages and fix them.'); 166 throw new \RuntimeException('Some system requirements are not fulfilled. Please check output messages and fix them.');
153 } 167 }
154 168
155 $this->defaultOutput->writeln('<info>Success! Your system can run Wallabag properly.</info>'); 169 $this->defaultOutput->writeln('<info>Success! Your system can run wallabag properly.</info>');
156 170
157 $this->defaultOutput->writeln(''); 171 $this->defaultOutput->writeln('');
158 172
@@ -299,6 +313,16 @@ class InstallCommand extends ContainerAwareCommand
299 'section' => 'entry', 313 'section' => 'entry',
300 ], 314 ],
301 [ 315 [
316 'name' => 'share_unmark',
317 'value' => '1',
318 'section' => 'entry',
319 ],
320 [
321 'name' => 'unmark_url',
322 'value' => 'https://unmark.it',
323 'section' => 'entry',
324 ],
325 [
302 'name' => 'share_shaarli', 326 'name' => 'share_shaarli',
303 'value' => '1', 327 'value' => '1',
304 'section' => 'entry', 328 'section' => 'entry',
@@ -375,7 +399,7 @@ class InstallCommand extends ContainerAwareCommand
375 ], 399 ],
376 [ 400 [
377 'name' => 'wallabag_url', 401 'name' => 'wallabag_url',
378 'value' => 'http://v2.wallabag.org', 402 'value' => '',
379 'section' => 'misc', 403 'section' => 'misc',
380 ], 404 ],
381 [ 405 [
@@ -403,6 +427,16 @@ class InstallCommand extends ContainerAwareCommand
403 'value' => 'wallabag', 427 'value' => 'wallabag',
404 'section' => 'misc', 428 'section' => 'misc',
405 ], 429 ],
430 [
431 'name' => 'download_images_enabled',
432 'value' => '0',
433 'section' => 'misc',
434 ],
435 [
436 'name' => 'restricted_access',
437 'value' => '0',
438 'section' => 'entry',
439 ],
406 ]; 440 ];
407 441
408 foreach ($settings as $setting) { 442 foreach ($settings as $setting) {