@@ -46,21 +46,44 @@ protected function listBundles($output)
4646 protected function findExtension ($ name )
4747 {
4848 $ bundles = $ this ->initializeBundles ();
49+ $ minScore = INF ;
50+
4951 foreach ($ bundles as $ bundle ) {
52+ $ distance = levenshtein ($ name , $ bundle ->getName ());
53+
54+ if ($ distance < $ minScore ) {
55+ $ guess = $ bundle ->getName ();
56+ $ minScore = $ distance ;
57+ }
58+
5059 if ($ name === $ bundle ->getName ()) {
5160 return $ bundle ->getContainerExtension ();
5261 }
5362
5463 $ extension = $ bundle ->getContainerExtension ();
55- if ($ extension && $ name === $ extension ->getAlias ()) {
56- return $ extension ;
64+
65+ if ($ extension ) {
66+ if ($ name === $ extension ->getAlias ()) {
67+ return $ extension ;
68+ }
69+
70+ $ distance = levenshtein ($ name , $ extension ->getAlias ());
71+
72+ if ($ distance < $ minScore ) {
73+ $ guess = $ extension ->getAlias ();
74+ $ minScore = $ distance ;
75+ }
5776 }
5877 }
5978
6079 if ('Bundle ' !== substr ($ name , -6 )) {
61- $ message = sprintf ('No extensions with configuration available for "%s" ' , $ name );
80+ $ message = sprintf ('No extensions with configuration available for "%s". ' , $ name );
6281 } else {
63- $ message = sprintf ('No extension with alias "%s" is enabled ' , $ name );
82+ $ message = sprintf ('No extension with alias "%s" is enabled. ' , $ name );
83+ }
84+
85+ if (isset ($ guess ) && $ minScore < 3 ) {
86+ $ message .= sprintf ("\n\nDid you mean \"%s \"? " , $ guess );
6487 }
6588
6689 throw new \LogicException ($ message );
0 commit comments