The following steps can be followed to get things running for the first time:
1. Copy the `.env.example` file to `.env` and configure its values as required.
2. Create a new database named whatever you've set `DB_DATABASE` to in the `.env` file.
3. Run the `init.sh` script and wait for it to complete.
### Environment File
The `.env` file includes deployment-specific configuration options, and Laravel has documentation explaining it in further detail [HERE](https://laravel.com/docs/configuration).
The `APP_ENV` and `APP_DEBUG` variables should be configured in one of the following combinations depending on the scenario:
* Local development should be configured with `APP_ENV=local` and `APP_DEBUG=true`.
* A remote staging server should be configured with `APP_ENV=staging` and `APP_DEBUG=true`.
* A remote production server should be configured with `APP_ENV=production` and `APP_DEBUG=false`.
### Init Script
The `init.sh` script is located in the root of the project and is used to keep the database and compiled assets in sync with the codebase.
It's the recommended way to handle the initial project setup, and can also be run manually or by deployment scripts to keep things up to date after pulling in changes.
The following steps are performed in this order when run:
1. Checks the local system for dependencies required by the script and exits with an error if any are missing.
2. Checks to see if the `.env` file exists and exits with an error if it doesn't.
3. (artisan) Puts the website in maintenance mode.
4. Downloads and updates non-development composer dependencies.
5. Checks to see if the `APP_KEY` variable in the `.env` file is empty, and if it is, generates a value for it.
6. Clears the route and blade cache to ensure everything will be build fresh against the current codebase and dependencies.
7. Updates the `CACHE_BUST` variable in the `.env` file, which changes the value of a `version` query string appended to compiled assets and prevents clients from using a previous version in their cache.
8. (artisan) Run new database migrations.
9. Cleans, downloads and updates npm dependencies.
10. Cleans, downloads and updates bower dependencies.
11. Builds `public/fonts` with `gulp --production` (using the local version of gulp installed in `node_modules`).
12. (artisan) Takes the website out of maintenance mode.
**NOTE**: Items with `(artisan)` prepended to them won't be run if `init.sh` is run with the `--no-artisan` flag.
In the root of the project is a file named `gulpfile.js` that can be used by `gulp` to copy fonts, compile javascript and sass, and watch files for changes during development.
Reading through its contents is encouraged for a complete understanding of what it does, but the following commands should handle most of what it's needed for out of the box:
*`gulp`: Update the compiled javascript and css in `public/js` and `public/css`, and copy fonts to `public/fonts`.
*`gulp --production`: Does the same as `gulp` except the compiled javascript and css is minified, and console logging is removed from the javascript (good for production deployments).
*`gulp default watch`: Does the same as `gulp` but continues running to watch for changes to files so it can recompile updated assets and reload them in the browser using BrowserSync (good for development environments).
BrowserSync is used to keep the browser in sync with your code when running the `watch` task with gulp.
For this to work on browsers that aren't on the computer running gulp, the `BS_HOST` variable in the `.env` file should be set to the IP address of that computer.
The default public facing website uses vue.js. To configure a non-SPA traditional website, look at the files in `traditional-bootstrap`.
The following list of files and directories are where various pieces of the public website are located:
*`resources/views/templates/base.blade.php`: The outer template for the entire website
*`resources/views/templates/public.blade.php`: The inner template for the public site
*`resources/assets/fonts`: The folder containing website fonts (these get loaded into `public/fonts/` by the gulpfile)
*`resources/assets/js/app.js`: The main javascript file that loads the public site
*`resources/assets/js/mixins`: The folder containing vue.js mixins that can be applied globally in `resources/assets/js/app.js` or in individual components
*`resources/assets/js/mixins/base-page.js`: The base-page mixin with page functionality that should be imported into all page components
*`resources/components`: The folder containing vue.js components
*`resources/components/pages`: Page components that should be imported into vue-router in `resources/assets/js/app.js`
*`resources/components/sections`: Section components (single-use per page) that should be imported into mixins or page components
*`resources/components/partials`: Partial components (multi-use per page or section) that should be imported into mixins and/or page and section components
*`resources/assets/sass/app.scss`: The main sass file for the public site
*`resources/assets/sass/_fonts.scss`: Stylesheet containing font declarations and mixins declared to use those fonts in other stylesheets
*`resources/assets/sass/_var.scss`: Stylesheet containing variables to be used in other stylesheets
*`resources/assets/sass/pages`: Stylesheets for page-specific styles wrapped in the respective page component class
*`resources/assets/sass/sections`: Stylesheets for section-specific styles wrapped in the respective section component class
*`resources/assets/sass/partials`: Stylessheets for partial-specific styles wrapped in the respective partial component class
*`resources/assets/sass/classes`: General stylesheets for classes that can be used anywhere
*`resources/assets/sass/mixins`: Stylesheets declaring SCSS mixins for use in other stylesheets
Dependencies can be included with bower or npm and loaded either into the `jsPublicLibs` array in the gulpfile or imported in the javascript.
Other information about database interaction, routing, controllers, etc can be viewed in the [Laravel Documentation](https://laravel.com/docs).
The default language is set by the `DEFAULT_LANGUAGE` variable in the `.env` file. This will be the language used until it is changed, which can be done using the `/language/{lang}` route or directly using `Language::setSessionLanguage($lang)` where in both cases `lang` is the language code for a given language.
In the view, a block of text can be configured with multiple languages using the following syntax:
```php
@lang([
'en' => "This is a sentence",
'fr' => "C'est une phrase"
])
```
or
```php
{{ Language::select([ 'en' => "This is a sentence", 'fr' => "C'est une phrase" ]) }}
*`$create`: A boolean determining whether to enable a button that allows new records to be created
*`$delete`: A boolean determining whether to enable a button that allows records to be deleted
*`$filter`: A boolean determining whether to enable an input field that allows records to be searched
*`$dashboard_help_text`: An html string that will add a help box to the top of the edit-item page
*`$dashboard_display`: An array to configure what column data to show on each item in the edit-list
*`$dashboard_reorder`: A boolean determining whether to render drag handles to reorder the items in the list
*`$dashboard_sort_column`: A string containing the column used to sort the list (this should be an `integer` when `$dashboard_reorder` is true)
*`$dashboard_sort_direction`: When `$dashboard_reorder` is false this determines the sort direction (this can be `desc` for descending or `asc` ascending)
*`$dashboard_button`: An array containing the following items in this order:
* The title
* Confirmation text asking the user to confirm
* A "success" message to display when the response is `success`
* A "failure" message to display when the response is not `success`
* The URL to send the POST request to with the respective `id` in the request variable