@@ -26,11 +26,6 @@ class RepositoryServiceProvider extends ServiceProvider
2626 */
2727 public function register ()
2828 {
29- // check ensure main folder services
30- $ this ->app ->make (Filesystem::class)->ensureDirectoryExists (config ("easy-repository.service_directory " ));
31- // check ensure main folder repository
32- $ this ->app ->make (Filesystem::class)->ensureDirectoryExists (config ("easy-repository.repository_directory " ));
33-
3429 $ this ->files = $ this ->app ->make (Filesystem::class);
3530 if ($ this ->isConfigPublished ()) {
3631 $ this ->bindAllRepositories ();
@@ -125,16 +120,20 @@ public function getRepository()
125120 */
126121 private function getRepositoryPath ()
127122 {
128- $ dirs = File::directories ($ this ->app ->basePath () .
129- "/ " . config ("easy-repository.repository_directory " ));
130123 $ folders = [];
124+ if (file_exists ($ this ->app ->basePath () . "/ " . config ("easy-repository.repository_directory " ))) {
125+ $ dirs = File::directories ($ this ->app ->basePath () .
126+ "/ " . config ("easy-repository.repository_directory " ));
127+ foreach ($ dirs as $ dir ) {
128+ $ arr = explode ("/ " , $ dir );
131129
132- foreach ($ dirs as $ dir ) {
133- $ arr = explode ("/ " , $ dir );
130+ $ folders [] = end ($ arr );
131+ }
132+ } else {
134133
135- $ folders [] = end ($ arr );
136134 }
137135
136+
138137 return $ folders ;
139138 }
140139
@@ -195,13 +194,17 @@ private function getRepositoryFiles()
195194 private function getServicePath () {
196195 $ root = $ this ->app ->basePath () .
197196 "/ " . config ("easy-repository.service_directory " );
197+ $ servicePath = [];
198198
199- $ path = Search::file ($ root , ["php " ]);
199+ if (file_exists ($ root )) {
200+ $ path = Search::file ($ root , ["php " ]);
200201
201- $ servicePath = [];
202- foreach ($ path as $ file ) {
203- $ servicePath [] = str_replace ("Services/ " ,"" ,strstr ($ file ->getPath (), "Services " ));
202+
203+ foreach ($ path as $ file ) {
204+ $ servicePath [] = str_replace ("Services/ " ,"" ,strstr ($ file ->getPath (), "Services " ));
205+ }
204206 }
207+
205208 return array_unique ($ servicePath );
206209 }
207210
0 commit comments