@@ -142,10 +142,13 @@ protected function readPassword(InputInterface $input, OutputInterface $output)
142142 if ($ input ->isInteractive ()) {
143143 /** @var QuestionHelper $helper */
144144 $ helper = $ this ->getHelper ('question ' );
145- $ question = new Question ('What is the database password? ' );
145+ $ question = new Question ('What is the database password (press <enter> for none)? ' );
146146 $ question ->setHidden (true );
147147 $ question ->setHiddenFallback (false );
148148 $ password = $ helper ->ask ($ input , $ output , $ question );
149+ if ($ password === null ) {
150+ $ password = '' ; // possibly unnecessary
151+ }
149152 $ input ->setOption ('password ' , $ password );
150153 return ;
151154 }
@@ -233,9 +236,24 @@ protected function getToDBConnection(InputInterface $input, OutputInterface $out
233236 'password ' => $ input ->getOption ('password ' ),
234237 'dbname ' => $ input ->getArgument ('database ' ),
235238 ]);
239+
240+ // parse port
236241 if ($ input ->getOption ('port ' )) {
237242 $ connectionParams ['port ' ] = $ input ->getOption ('port ' );
238243 }
244+
245+ // parse hostname for unix socket
246+ if (preg_match ('/^(.+)(:(\d+|[^:]+))?$/ ' , $ input ->getOption ('hostname ' ), $ matches )) {
247+ $ connectionParams ['host ' ] = $ matches [1 ];
248+ if (isset ($ matches [3 ])) {
249+ if (is_numeric ($ matches [3 ])) {
250+ $ connectionParams ['port ' ] = $ matches [3 ];
251+ } else {
252+ $ connectionParams ['unix_socket ' ] = $ matches [3 ];
253+ }
254+ }
255+ }
256+
239257 return $ this ->connectionFactory ->getConnection ($ type , $ connectionParams );
240258 }
241259
0 commit comments