Skip to content

Commit

Permalink
Fix: crashing installer, missing installer env builder entries, crash…
Browse files Browse the repository at this point in the history
…ing composer install when .env is missing
  • Loading branch information
Volmarg committed Oct 25, 2020
1 parent f80319a commit 163cd14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
27 changes: 19 additions & 8 deletions src/AutoInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ class AutoInstaller{

const PUBLIC_DIR = 'public';

const UPLOAD_DIR = 'upload';
const UPLOAD_DIR_IMAGES = 'upload/images';
const UPLOAD_DIR_FILES = 'upload/files';
const UPLOAD_DIR = 'upload';
const UPLOAD_DIR_IMAGES = 'upload/images';
const UPLOAD_DIR_FILES = 'upload/files';
const UPLOAD_DIR_MINIATURES = 'upload/miniatures';

const APP_SECRET = 'b9abc19ae10d53eb7cf5b5684ec6511f';

Expand All @@ -46,6 +47,8 @@ class AutoInstaller{
const ENV_KEY_UPLOAD_DIR = 'UPLOAD_DIR';
const ENV_KEY_IMAGES_UPLOAD_DIR = 'IMAGES_UPLOAD_DIR';
const ENV_KEY_FILES_UPLOAD_DIR = 'FILES_UPLOAD_DIR';
const ENV_KEY_MINIATURES_UPLOAD_DIR = 'MINIATURES_UPLOAD_DIR';
const ENV_KEY_PUBLIC_ROOT_DIR = 'PUBLIC_ROOT_DIR';

static $is_node_installed = false;

Expand Down Expand Up @@ -288,9 +291,9 @@ private static function buildEnv(){
}

if( file_exists($env_file_name) ){
CliHandler::errorText("Env file already exist so I'm aborting. Copy Your env or remove it and let the installer proceed.");
CliHandler::errorText("Env file already exist so It won't be modified - You must do this manually then.");
self::installerAreaLine();
exit();
return;
}

$database_url = "mysql://{$db_login}:{$db_password}@{$db_host}:{$db_port}/{$db_name}";
Expand All @@ -310,8 +313,10 @@ private static function buildEnv(){
fwrite($file_handler,self::ENV_KEY_MAILER_URL . "=" . self::MAILER_URL . PHP_EOL);
fwrite($file_handler,self::ENV_KEY_DATABASE_URL . "=" . $database_url . PHP_EOL);
fwrite($file_handler,self::ENV_KEY_UPLOAD_DIR . "=" . self::UPLOAD_DIR . PHP_EOL);
fwrite($file_handler,self::ENV_KEY_IMAGES_UPLOAD_DIR . "=" . self::UPLOAD_DIR_IMAGES . PHP_EOL);
fwrite($file_handler,self::ENV_KEY_FILES_UPLOAD_DIR . "=" . self::UPLOAD_DIR_FILES . PHP_EOL);
fwrite($file_handler,self::ENV_KEY_IMAGES_UPLOAD_DIR . "=" . self::UPLOAD_DIR_IMAGES . PHP_EOL);
fwrite($file_handler,self::ENV_KEY_FILES_UPLOAD_DIR . "=" . self::UPLOAD_DIR_FILES . PHP_EOL);
fwrite($file_handler,self::ENV_KEY_MINIATURES_UPLOAD_DIR . "=" . self::UPLOAD_DIR_MINIATURES . PHP_EOL);
fwrite($file_handler,self::ENV_KEY_PUBLIC_ROOT_DIR . "=" . self::PUBLIC_DIR . PHP_EOL);
}
fclose($file_handler);
CliHandler::infoText('Env file has been created.');
Expand All @@ -326,6 +331,7 @@ private function setDatabase(){
$drop_database_command = "bin/console doctrine:database:drop -n --force";
$create_database_command = "bin/console doctrine:database:create -n";
$build_tables = "bin/console doctrine:schema:update -n --env=dev --force"; //there is symfony bug so it must be done like this
$run_migrations = "bin/console doctrine:migrations:migrate -n";

shell_exec($drop_database_command);
CliHandler::text("Database has been dropped (if You provided the existing one)");
Expand All @@ -336,7 +342,12 @@ private function setDatabase(){
CliHandler::text("Creating database tables, please wait");

shell_exec($build_tables);
CliHandler::text("Database tables has been created", false);
CliHandler::text("Database tables has been created");

CliHandler::text("Inserting base data into the tables, please wait");

shell_exec($run_migrations);
CliHandler::text("Base data base been inserted into the tables", false);

}
CliHandler::infoText("Finished configuring the database.");
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/DoctrineTypes/SerializedJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class SerializedJson extends Type
{
const TYPE_NAME = 'serialized_json'; // modify to match your type name

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $column, AbstractPlatform $platform)
{
// return the SQL used to create your column type. To create a portable column type, use the $platform.
return $platform->getVarcharTypeDeclarationSQL($column);
}

public function convertToPHPValue($value, AbstractPlatform $platform)
Expand Down

0 comments on commit 163cd14

Please sign in to comment.