Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
57838ec1
Commit
57838ec1
authored
Oct 12, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Writing the database informations
parent
f7367785
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
2 deletions
+55
-2
InstallCommand.php
Modules/Core/Console/InstallCommand.php
+53
-1
CoreServiceProvider.php
Modules/Core/Providers/CoreServiceProvider.php
+2
-1
No files found.
Modules/Core/Console/InstallCommand.php
View file @
57838ec1
<?php
namespace
Modules\Core\Console
;
use
Illuminate\Console\Command
;
use
Illuminate\Filesystem\Filesystem
;
use
Illuminate\Support\Facades\Hash
;
use
Modules\User\Repositories\RoleRepository
;
use
Modules\User\Repositories\UserRepository
;
...
...
@@ -30,19 +31,25 @@ class InstallCommand extends Command
* @var RoleRepository
*/
private
$role
;
/**
* @var Filesystem
*/
private
$finder
;
/**
* Create a new command instance.
*
* @param UserRepository $user
* @param RoleRepository $role
* @param Filesystem $finder
* @return \Modules\Core\Console\InstallCommand
*/
public
function
__construct
(
$user
,
$role
)
public
function
__construct
(
$user
,
$role
,
Filesystem
$finder
)
{
parent
::
__construct
();
$this
->
user
=
$user
;
$this
->
role
=
$role
;
$this
->
finder
=
$finder
;
}
/**
...
...
@@ -54,6 +61,8 @@ class InstallCommand extends Command
{
$this
->
info
(
'Starting the installation process...'
);
$this
->
configureDatabase
();
$this
->
runMigrations
();
$this
->
runSeeds
();
...
...
@@ -129,4 +138,47 @@ class InstallCommand extends Command
{
$this
->
call
(
'module:publish'
,
[
'module'
=>
'Core'
]);
}
/**
* Configuring the database information
*/
private
function
configureDatabase
()
{
// Ask for credentials
$databaseName
=
$this
->
ask
(
'Enter your database name'
);
$databaseUsername
=
$this
->
ask
(
'Enter your database username'
);
$databasePassword
=
$this
->
secret
(
'Enter your database password'
);
$this
->
configureEnvironmentFile
(
$databaseName
,
$databaseUsername
,
$databasePassword
);
}
/**
* Writing the environment file
* @param $databaseName
* @param $databaseUsername
* @param $databasePassword
*/
private
function
configureEnvironmentFile
(
$databaseName
,
$databaseUsername
,
$databasePassword
)
{
$environmentFile
=
$this
->
finder
->
get
(
'.env.example'
);
$search
=
[
"DB_USERNAME=homestead"
,
"DB_PASSWORD=homestead"
];
$replace
=
[
"DB_USERNAME=
$databaseUsername
"
,
"DB_PASSWORD=
$databasePassword
"
.
PHP_EOL
];
$newEnvironmentFile
=
str_replace
(
$search
,
$replace
,
$environmentFile
);
$newEnvironmentFile
.=
"DB_NAME=
$databaseName
"
;
// Write the new environment file
$this
->
finder
->
put
(
'.env'
,
$newEnvironmentFile
);
// Delete the old environment file
$this
->
finder
->
delete
(
'env.example'
);
$this
->
info
(
'Environment file written'
);
}
}
Modules/Core/Providers/CoreServiceProvider.php
View file @
57838ec1
...
...
@@ -106,7 +106,8 @@ class CoreServiceProvider extends ServiceProvider
$this
->
app
->
bindShared
(
'command.platform.install'
,
function
(
$app
)
{
return
new
InstallCommand
(
$app
[
'Modules\User\Repositories\UserRepository'
],
$app
[
'Modules\User\Repositories\RoleRepository'
]
$app
[
'Modules\User\Repositories\RoleRepository'
],
$app
[
'files'
]
);
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment