From 9f386df16af06459bc5779dcd9a5f73c4cbcb91e Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Wed, 29 Jul 2020 10:29:34 +0300 Subject: [PATCH] Updated controllers naming --- app/config/services.php | 28 ++++++++++---------- app/{app.php => controllers/general.php} | 6 ++--- app/http.php | 2 +- app/preload.php | 4 +-- app/tasks/install.php | 33 ++++++++++++------------ public/index.php | 2 +- 6 files changed, 38 insertions(+), 37 deletions(-) rename app/{app.php => controllers/general.php} (99%) diff --git a/app/config/services.php b/app/config/services.php index cf5ee43926..e500f9a241 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -3,96 +3,96 @@ return [ '/' => [ 'name' => 'Homepage', - 'controller' => 'controllers/web/home.php', + 'controller' => 'web/home.php', 'sdk' => false, 'tests' => false, ], 'console/' => [ 'name' => 'Console', - 'controller' => 'controllers/web/console.php', + 'controller' => 'web/console.php', 'sdk' => false, 'tests' => false, ], 'v1/account' => [ 'name' => 'Account', 'description' => '/docs/services/account.md', - 'controller' => 'controllers/api/account.php', + 'controller' => 'api/account.php', 'sdk' => true, 'tests' => false, ], 'v1/avatars' => [ 'name' => 'Avatars', 'description' => '/docs/services/avatars.md', - 'controller' => 'controllers/api/avatars.php', + 'controller' => 'api/avatars.php', 'sdk' => true, 'tests' => false, ], 'v1/database' => [ 'name' => 'Database', 'description' => '/docs/services/database.md', - 'controller' => 'controllers/api/database.php', + 'controller' => 'api/database.php', 'sdk' => true, 'tests' => false, ], 'v1/locale' => [ 'name' => 'Locale', 'description' => '/docs/services/locale.md', - 'controller' => 'controllers/api/locale.php', + 'controller' => 'api/locale.php', 'sdk' => true, 'tests' => false, ], 'v1/health' => [ 'name' => 'Health', 'description' => '/docs/services/health.md', - 'controller' => 'controllers/api/health.php', + 'controller' => 'api/health.php', 'sdk' => true, 'tests' => false, ], 'v1/projects' => [ 'name' => 'Projects', - 'controller' => 'controllers/api/projects.php', + 'controller' => 'api/projects.php', 'sdk' => true, 'tests' => false, ], 'v1/storage' => [ 'name' => 'Storage', 'description' => '/docs/services/storage.md', - 'controller' => 'controllers/api/storage.php', + 'controller' => 'api/storage.php', 'sdk' => true, 'tests' => false, ], 'v1/teams' => [ 'name' => 'Teams', 'description' => '/docs/services/teams.md', - 'controller' => 'controllers/api/teams.php', + 'controller' => 'api/teams.php', 'sdk' => true, 'tests' => false, ], 'v1/users' => [ 'name' => 'Users', 'description' => '/docs/services/users.md', - 'controller' => 'controllers/api/users.php', + 'controller' => 'api/users.php', 'sdk' => true, 'tests' => false, ], 'v1/functions' => [ 'name' => 'Users', 'description' => '/docs/services/functions.md', - 'controller' => 'controllers/api/functions.php', + 'controller' => 'api/functions.php', 'sdk' => true, 'tests' => false, ], 'v1/mock' => [ 'name' => 'Mock', 'description' => '', - 'controller' => 'controllers/mock.php', + 'controller' => 'mock.php', 'sdk' => false, 'tests' => true, ], 'v1/graphql' => [ 'name' => 'GraphQL', 'description' => 'GraphQL Endpoint', - 'controller' => 'controllers/api/graphql.php', + 'controller' => 'api/graphql.php', 'sdk' => false, 'tests' => false, ], diff --git a/app/app.php b/app/controllers/general.php similarity index 99% rename from app/app.php rename to app/controllers/general.php index 90a2580e87..751e6cdb04 100644 --- a/app/app.php +++ b/app/controllers/general.php @@ -1,6 +1,6 @@ text($content); }, ['request', 'response']); -include_once __DIR__ . '/controllers/shared/api.php'; -include_once __DIR__ . '/controllers/shared/web.php'; +include_once __DIR__ . '/shared/api.php'; +include_once __DIR__ . '/shared/web.php'; foreach(Config::getParam('services', []) as $service) { include_once $service['controller']; diff --git a/app/http.php b/app/http.php index fd4f260a4d..9540375430 100644 --- a/app/http.php +++ b/app/http.php @@ -63,7 +63,7 @@ $http->on('start', function (Server $http) use ($payloadSize) { Files::load(__DIR__ . '/../public'); -include __DIR__ . '/app.php'; +include __DIR__ . '/controllers/general.php'; $domain = App::getEnv('_APP_DOMAIN', ''); diff --git a/app/preload.php b/app/preload.php index 7e5fe66543..e01a39abab 100644 --- a/app/preload.php +++ b/app/preload.php @@ -18,8 +18,8 @@ if (file_exists(__DIR__.'/../vendor/autoload.php')) { use Appwrite\Preloader\Preloader; -include 'init.php'; -include 'app.php'; +include './init.php'; +include './controllers/general.php'; (new Preloader()) ->paths(realpath(__DIR__ . '/../app/config')) diff --git a/app/tasks/install.php b/app/tasks/install.php index e00f761dcc..815cd57967 100644 --- a/app/tasks/install.php +++ b/app/tasks/install.php @@ -17,7 +17,7 @@ $cli * 2.2. Get ENV vars * 2.2.1 Fetch from older docker-compose.yml file * 2.2.2 Fetch from older .env file (manually parse) - * 2.3 Use old ENV vars as default values + * 2.3 Use old ENV vars as default values * 2.4 Ask for all required vars not given as CLI args and if in interactive mode * Otherwise, just use default vars. - DONE * 3. Ask user to backup important volumes, env vars, and SQL tables @@ -26,21 +26,16 @@ $cli * 5. Run docker-compose up -d - DONE * 6. Run data migration */ - $vars = Config::getParam('variables'); Console::success('Starting Appwrite installation...'); - if(!empty($httpPort)) { - $httpPort = Console::confirm('Choose your server HTTP port: (default: 80)'); - $httpPort = ($httpPort) ? $httpPort : 80; - } - - if(!empty($httpsPort)) { - $httpsPort = Console::confirm('Choose your server HTTPS port: (default: 443)'); - $httpsPort = ($httpsPort) ? $httpsPort : 443; - } - + $httpPort = Console::confirm('Choose your server HTTP port: (default: 80)'); + $httpPort = ($httpPort) ? $httpPort : 80; + + $httpsPort = Console::confirm('Choose your server HTTPS port: (default: 443)'); + $httpsPort = ($httpsPort) ? $httpsPort : 443; + $input = []; foreach($vars as $key => $var) { @@ -56,8 +51,8 @@ $cli } } - $templateForCompose = new View('../views/install/compose.phtml'); - $templateForEnv = new View('../views/install/env.phtml'); + $templateForCompose = new View(__DIR__.'/../views/install/compose.phtml'); + $templateForEnv = new View(__DIR__.'/../views/install/env.phtml'); $templateForCompose ->setParam('httpPort', $httpPort) @@ -71,12 +66,12 @@ $cli $path = '/usr/src/code'; - if(!file_put_contents($path.'/docker-compose.yml', $templateForCompose->render())) { + if(!file_put_contents($path.'/docker-compose.yml', $templateForCompose->render(false))) { Console::error('Failed to save Docker Compose file'); exit(1); } - if(!file_put_contents($path.'/.env', $templateForEnv->render())) { + if(!file_put_contents($path.'/.env', $templateForEnv->render(false))) { Console::error('Failed to save environment variables file'); exit(1); } @@ -91,4 +86,10 @@ $cli } else { Console::success("Appwrite installed successfully"); } + + $files1 = scandir($path); + + var_dump($files1); + var_dump(file_get_contents($path.'/.env')); + var_dump(file_get_contents($path.'/docker-compose.yml')); }); \ No newline at end of file diff --git a/public/index.php b/public/index.php index 3aa0984c71..01f9dbb117 100644 --- a/public/index.php +++ b/public/index.php @@ -20,7 +20,7 @@ ini_set('display_startup_errors', 1); error_reporting(E_ALL); //trigger_error('hide errors in prod', E_USER_NOTICE); -include __DIR__ . '/../app/app.php'; +include __DIR__ . '/../app/controllers/general.php'; $app = new App('Asia/Tel_Aviv');