document installation options #64 (#65)

This commit is contained in:
Kevin Papst
2018-01-09 13:09:33 +01:00
committed by GitHub
parent ae8df0966c
commit 56fca32845
3 changed files with 60 additions and 49 deletions

View File

@@ -12,6 +12,7 @@ It is based on the following PHP components:
- [Symfony Framework 3.4](https://github.com/symfony/symfony) - [Symfony Framework 3.4](https://github.com/symfony/symfony)
- [AdminThemeBundle](https://github.com/avanzu/AdminThemeBundle/) (based on [AdminLTE](https://github.com/almasaeed2010/AdminLTE/)) - [AdminThemeBundle](https://github.com/avanzu/AdminThemeBundle/) (based on [AdminLTE](https://github.com/almasaeed2010/AdminLTE/))
- [Doctrine](https://github.com/doctrine/) - [Doctrine](https://github.com/doctrine/)
- Bower
## Requirements ## Requirements
@@ -23,7 +24,7 @@ If unsure about meeting these requirements, download the demo application and
browse the `http://localhost:8000/config.php` script to get more detailed browse the `http://localhost:8000/config.php` script to get more detailed
information. information.
## Installation ## Installation (dev)
First, install Git and [Composer](https://getcomposer.org/doc/00-intro.md) First, install Git and [Composer](https://getcomposer.org/doc/00-intro.md)
if you haven't already. Then, clone this repo and execute this command in the cloned directory: if you haven't already. Then, clone this repo and execute this command in the cloned directory:
@@ -31,26 +32,23 @@ if you haven't already. Then, clone this repo and execute this command in the cl
```bash ```bash
$ git clone https://github.com/kevinpapst/kimai2.git $ git clone https://github.com/kevinpapst/kimai2.git
$ cd kimai2/ $ cd kimai2/
```
Lets prepare the environment by installing all dependencies. You will be asked for your application parameter,
like the database connection afterwards (if you don't have a app/config/parameters.yml yet):
```bash
$ composer install $ composer install
``` ```
Lets prepare the environment The next command will create the database, the schema and install all web assets:
```bash ```bash
$ php bin/console assets:install --symlink --relative $ php bin/console kimai:install --relative
$ php bin/console avanzu:admin:initialize --symlink --relative
``` ```
This was the basic task of the installation. If you have not yet setup a database, you ### Installation (live)
can create it and import example data by executing these commands:
```bash
$ cd kimai2/
$ php bin/console doctrine:database:create
$ php bin/console doctrine:schema:create
```
### Creating your first user All thats left to do is to create your first user:
As there is currently no full-fledged installer, you need to create the first user via command-line:
```bash ```bash
$ php bin/console kimai:create-user admin admin@example.com password en ROLE_SUPER_ADMIN $ php bin/console kimai:create-user admin admin@example.com password en ROLE_SUPER_ADMIN
@@ -58,33 +56,38 @@ $ php bin/console kimai:create-user admin admin@example.com password en ROLE_SUP
For available roles, please refer to [the user documentation](app/Resources/docs/users.md). For available roles, please refer to [the user documentation](app/Resources/docs/users.md).
### Installation (dev)
### Demo data Lets boostrap your dev environment by executing this commands:
You can also import demo data, to test the application in its full beauty and with several different user accounts and permission sets.
```bash ```bash
$ php bin/console doctrine:fixtures:load $ php bin/console kimai:dev:reset
``` ```
If you have imported the example data, you can login with these accounts: You just imported demo data, to test the application in its full beauty and with several different user accounts and permission sets!
You can now login with these accounts:
- Username: *clara_customer* / Password: *kitten* / Role: Customer - Username: *clara_customer* / Password: *kitten* / Role: Customer
- Username: *john_user* / Password: *kitten* / Role: User - Username: *john_user* / Password: *kitten* / Role: User
- Username: *chris_user* / Password: *kitten* / Role: User (deactivated for login tests)
- Username: *tony_teamlead* / Password: *kitten* / Role: Teamlead - Username: *tony_teamlead* / Password: *kitten* / Role: Teamlead
- Username: *anna_admin* / Password: *kitten* / Role: Administrator - Username: *anna_admin* / Password: *kitten* / Role: Administrator
- Username: *susan_super* / Password: *kitten* / Role: Super-Administrator - Username: *susan_super* / Password: *kitten* / Role: Super-Administrator
Demo data can always be deleted by dropping the schema and re-creating it (ATTENTION: this will erase all your data!): Demo data can always be deleted by dropping the schema and re-creating it.
ATTENTION - this will erase all your data:
```bash ```bash
$ php bin/console doctrine:schema:drop --force $ php bin/console doctrine:schema:drop --force
$ php bin/console doctrine:schema:create $ php bin/console doctrine:schema:create
``` ```
The `kimai:dev:reset` command can always be executed later on to reset your dev database and cache. I use it very frequently.
## Usage ## Usage
There is no need to configure a virtual host in your web server to access the application. There is no need to configure a virtual host in your web server to access the application for testing.
Just use the built-in web server for your first tests: Just use the built-in web server for your first tests:
```bash ```bash

View File

@@ -64,32 +64,32 @@ EOT
} }
} }
$command = $this->getApplication()->find('doctrine:database:create');
try { try {
$command = $this->getApplication()->find('doctrine:database:create');
$command->run(new ArrayInput([]), $output); $command->run(new ArrayInput([]), $output);
} catch (\Exception $ex) { } catch (\Exception $ex) {
$io->error('Failed to create database: ' . $ex->getMessage()); $io->error('Failed to create database: ' . $ex->getMessage());
return 1; return 1;
} }
$command = $this->getApplication()->find('doctrine:schema:drop');
try { try {
$command = $this->getApplication()->find('doctrine:schema:drop');
$command->run(new ArrayInput(['--force' => true]), $output); $command->run(new ArrayInput(['--force' => true]), $output);
} catch (\Exception $ex) { } catch (\Exception $ex) {
$io->error('Failed to drop database schema: ' . $ex->getMessage()); $io->error('Failed to drop database schema: ' . $ex->getMessage());
return 2; return 2;
} }
$command = $this->getApplication()->find('doctrine:schema:create');
try { try {
$command = $this->getApplication()->find('doctrine:schema:create');
$command->run(new ArrayInput([]), $output); $command->run(new ArrayInput([]), $output);
} catch (\Exception $ex) { } catch (\Exception $ex) {
$io->error('Failed to create database schema: ' . $ex->getMessage()); $io->error('Failed to create database schema: ' . $ex->getMessage());
return 3; return 3;
} }
$command = $this->getApplication()->find('doctrine:fixtures:load');
try { try {
$command = $this->getApplication()->find('doctrine:fixtures:load');
$cmdInput = new ArrayInput([]); $cmdInput = new ArrayInput([]);
$cmdInput->setInteractive(false); $cmdInput->setInteractive(false);
$command->run($cmdInput, $output); $command->run($cmdInput, $output);

View File

@@ -59,34 +59,42 @@ class InstallCommand extends Command
]; ];
} }
$this->installAssets($output, $io, 'avanzu:admin:initialize', $arguments); try {
$this->installAssets($output, $io, 'assets:install', $arguments); $command = $this->getApplication()->find('doctrine:database:create');
$this->installAssets($output, $io, 'avanzu:admin:fetch-vendor', []); $command->run(new ArrayInput([]), $output);
} } catch (\Exception $ex) {
$io->error('Failed to create database: ' . $ex->getMessage());
/** return 1;
* @param OutputInterface $output }
* @param SymfonyStyle $io
* @param string $cmdName
* @param array $args
* @return bool
*/
protected function installAssets(OutputInterface $output, SymfonyStyle $io, $cmdName, $args = [])
{
$command = $this->getApplication()->find($cmdName);
try { try {
$returnCode = $command->run(new ArrayInput($args), $output); $command = $this->getApplication()->find('doctrine:schema:create');
$command->run(new ArrayInput([]), $output);
} catch (\Exception $ex) { } catch (\Exception $ex) {
$io->error('Failed to install assets via "'.$cmdName.'": ' . $ex->getMessage()); $io->error('Failed to create database schema: ' . $ex->getMessage());
return false; return 2;
} }
if ($returnCode != 0) { try {
$io->error('Failed to install assets via "'.$cmdName.'"'); $command = $this->getApplication()->find('avanzu:admin:initialize');
return false; $command->run(new ArrayInput($arguments), $output);
} catch (\Exception $ex) {
$io->error('Failed to initialize avanzu theme: ' . $ex->getMessage());
return 3;
}
try {
$command = $this->getApplication()->find('assets:install');
$command->run(new ArrayInput($arguments), $output);
} catch (\Exception $ex) {
$io->error('Failed to install assets: ' . $ex->getMessage());
return 4;
}
try {
$command = $this->getApplication()->find('avanzu:admin:fetch-vendor');
$command->run(new ArrayInput([]), $output);
} catch (\Exception $ex) {
$io->error('Failed to fetch vendors for avanzu theme: ' . $ex->getMessage());
return 5;
} }
return true;
} }
} }