Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: upgrade to Laravel 10.x (resolves #1906) #1928

Merged
merged 24 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f181b9b
fix: prevent SAFE_MARKDOWN_OPTIONS from being defined repeatedly
greatislander Oct 10, 2023
7b8a9b3
fix: use Laravel console output for seeder messages
greatislander Oct 10, 2023
7f35934
feat!: upgrade to Laravel 10.x (resolves #1906)
greatislander Oct 10, 2023
8e4885e
Merge branch 'dev' into feat/upgrade-major-dependencies
greatislander Oct 10, 2023
2ae0386
fix: resolve static analysis errors
greatislander Oct 10, 2023
0daddd2
ci: fix database config for testing
greatislander Oct 10, 2023
e26ff94
test: add tests for scheduler
greatislander Oct 10, 2023
ed4c309
test: add test for SAFE_MARKDOWN_OPTIONS
greatislander Oct 10, 2023
c9ce5a5
Merge branch 'dev' into feat/upgrade-major-dependencies
greatislander Oct 10, 2023
3090af5
chore: fix lock file
greatislander Oct 10, 2023
89deaf3
ci: fix issues with test database
greatislander Oct 10, 2023
36567a3
ci: use new database name everywhere
greatislander Oct 10, 2023
4130a26
fix: move Markdown configuration to a config file
greatislander Oct 10, 2023
ce0c5d1
Merge branch 'dev' into feat/upgrade-major-dependencies
greatislander Oct 10, 2023
480ce80
chore: migrate expectations to pest
greatislander Oct 10, 2023
ee29dde
test: fix issue with browser tests
greatislander Oct 11, 2023
30d9e72
chore(docs): replace references to Laravel 9.x
greatislander Oct 11, 2023
b32f653
fix: resolve PR review comments
greatislander Oct 11, 2023
3c3025f
test: use toHaveCount in assertions where possible
greatislander Oct 11, 2023
be5f6b8
test: fix database reference
greatislander Oct 11, 2023
9d5fd68
test: remove example custom assertion
greatislander Oct 11, 2023
a227369
chore(docs): fix command
greatislander Oct 11, 2023
899ef84
chore: localize
greatislander Oct 11, 2023
5f40701
test: prevent timeouts when using composer scripts
greatislander Oct 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
if: steps.git-diff.outputs.diff
env:
APP_URL: "http://127.0.0.1:8000"
run: php artisan dusk
run: php artisan pest:dusk
- name: Upload Screenshots
if: failure()
uses: actions/upload-artifact@v3
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
if: steps.git-diff.outputs.diff
run: |
sudo systemctl start mysql.service
mysqladmin create accessibilityexchange --user="root" --password="root"
mysqladmin create tae-test --user="root" --password="root"
- name: Copy .env
if: steps.git-diff.outputs.diff
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
Expand All @@ -73,6 +73,7 @@ jobs:
- name: Run tests
if: steps.git-diff.outputs.diff && matrix.php == '8.2'
env:
DB_DATABASE: tae-test
DB_PASSWORD: root
DB_HOST: localhost
run: |
Expand All @@ -82,6 +83,7 @@ jobs:
- name: Run tests with coverage
if: steps.git-diff.outputs.diff && matrix.php == '8.1'
env:
DB_DATABASE: tae-test
DB_PASSWORD: root
DB_HOST: localhost
run: |
Expand Down
149 changes: 30 additions & 119 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ at [OCAD University](https://ocadu.ca).

## Technical Details

The platform is built as a progressive web application using the [Laravel 9](https://laravel.com/docs/9.x) framework.
The platform is built as a progressive web application using the [Laravel 10](https://laravel.com/docs/10.x) framework.

## Installation

For general deployment information, please see the Laravel 9.x [deployment documentation](https://laravel.com/docs/9.x/deployment).
For general deployment information, please see the Laravel 10.x [deployment documentation](https://laravel.com/docs/10.x/deployment).

The platform requires the following:

- [PHP](https://www.php.net/supported-versions.php) >= 8.1 with [required extensions](https://laravel.com/docs/9.x/deployment#server-requirements)
- [PHP](https://www.php.net/supported-versions.php) >= 8.1 with [required extensions](https://laravel.com/docs/10.x/deployment#server-requirements)
- [MySQL](https://dev.mysql.com/downloads/) >= 5.7
- [Composer](https://getcomposer.org) >= 2.0
- [Node](https://nodejs.org) >= 18

Optionally you may wish to install [NVM](https://github.com/nvm-sh/nvm) to make node version management easier.

The deployment process should follow all the recommended [optimization processes](https://laravel.com/docs/9.x/deployment#optimization).
The deployment process should follow all the recommended [optimization processes](https://laravel.com/docs/10.x/deployment#optimization).

## Development environments

Expand All @@ -55,12 +55,10 @@ php artisan migrate

## Development

Local development uses either the [Laravel Sail](https://laravel.com/docs/9.x/sail) Docker environment or [Laravel Valet](https://laravel.com/docs/9.x/valet).
Local development uses [Laravel Herd](https://herd.laravel.com/docs/1/getting-started/about-herd).

### Local development setup using Laravel Sail

1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop).
2. Add an alias to your shell [as described here](https://laravel.com/docs/9.x/sail#configuring-a-bash-alias).
1. Install [Herd](https://herd.laravel.com).
2. Install [Xdebug](https://herd.laravel.com/docs/1/advanced-usage/xdebug) or [PCOV](https://herd.laravel.com/docs/1/advanced-usage/additional-extensions) for code coverage.
3. Fork and clone the project repository (easiest with the [Github CLI](https://cli.github.com/)):

```bash
Expand All @@ -74,99 +72,13 @@ Local development uses either the [Laravel Sail](https://laravel.com/docs/9.x/sa
cp .env.example .env
```

Then, change the `APP_ENV` value to `local`:

```dotenv
APP_ENV=local
```

5. Generate an encryption key for [CipherSweet](https://github.com/spatie/laravel-ciphersweet):

```bash
openssl rand -hex 32
```

Add it to your `.env` file:

```dotenv
CIPHERSWEET_KEY="<your key>"
```

6. Start the development environment by running the following command from within the project directory:

```bash
sail up -d
```

7. Install Composer and NPM dependencies:

```bash
sail composer install
sail npm install
```

8. Generate an application key:

```bash
sail artisan key:generate
```

9. Run the required database migrations:

```bash
sail artisan migrate
```

10. Download the application fonts:

```bash
sail artisan google-fonts:fetch
```

For comprehensive instructions, consult the [Laravel documentation](https://laravel.com/docs/9.x). Here's an overview
of how some key tasks can be carried out using Sail:

- [Composer](https://getcomposer.org) commands may be executed by using `sail composer <command>`.
- [NPM](https://docs.npmjs.com/cli) commands may be executed by using `sail npm <command>`.
- [Artisan](https://laravel.com/docs/9.x/artisan) commands may be executed by using `sail artisan <command>`.

### Local development setup using Laravel Valet

1. Install [Homebrew](https://brew.sh).
2. Install PHP 8.1 via Homebrew:

```bash
brew install php@8.1
```

3. Install [Composer](https://getcomposer.org/).
4. Install Valet:

```bash
composer global require laravel/valet
valet install
```

5. Fork and clone the project repository (easiest with the [Github CLI](https://cli.github.com/)):

```bash
gh repo fork accessibility-exchange/platform --clone
cd platform
```

6. Create a `.env` file from the included example file:

```bash
cp .env.example .env
```

Then, change the `APP_ENV` value to `local`:

```dotenv
APP_ENV=local
```

8. Generate an encryption key for [CipherSweet](https://github.com/spatie/laravel-ciphersweet):
5. Generate an encryption key for [CipherSweet](https://github.com/spatie/laravel-ciphersweet):

```bash
openssl rand -hex 32
Expand All @@ -178,7 +90,7 @@ of how some key tasks can be carried out using Sail:
CIPHERSWEET_KEY="<your key>"
```

9. Install Composer and NPM dependencies:
6. Install Composer and NPM dependencies:

```bash
# install composer dependencies
Expand All @@ -192,40 +104,41 @@ of how some key tasks can be carried out using Sail:
npm ci
```

10. Generate an application key:
7. Generate an application key:

```bash
php artisan key:generate
```

11. Create a database:
8. Create a database for development and one for running tests:

```bash
mysql -uroot -e "create database accessibilityexchange;"
mysql -uroot -e "create database tae-test;"
```

12. Run the required database migrations:
9. Run the required database migrations:

```bash
php artisan migrate
```

13. Download the application fonts:
10. Download the application fonts:

```bash
php artisan google-fonts:fetch
```

14. Tell Valet to serve the application:
11. Tell Herd to serve the application:

```bash
valet link
herd link
```

15. Install [Mailhog](https://github.com/mailhog/MailHog) so that you can access transactional email from the platform:
12. Install [Mailpit](https://github.com/axllent/mailpit) so that you can access transactional email from the platform:

```bash
brew install mailhog
brew install mailpit
brew services start mailhog
greatislander marked this conversation as resolved.
Show resolved Hide resolved
```

Expand All @@ -237,19 +150,19 @@ of how some key tasks can be carried out using Sail:
MAIL_PORT=1025
```

You will now be able to access mail that the platform sends by visiting http://127.0.0.1:8025 or http://localhost:8025. For more information and additional configuration options, [read this blog post](https://ryangjchandler.co.uk/posts/setup-mailhog-with-laravel-valet).
You will now be able to access mail that the platform sends by visiting http://127.0.0.1:8025 or http://localhost:8025. For more information and additional configuration options, [read the Mailpit documentation](https://github.com/axllent/mailpit).

For comprehensive instructions, consult the [Laravel documentation](https://laravel.com/docs/9.x). Here's an overview
For comprehensive instructions, consult the [Laravel documentation](https://laravel.com/docs/10.x). Here's an overview
of how some key tasks can be carried out using Valet:

- [Composer](https://getcomposer.org) commands may be executed by using `composer <command>`.
- [NVM](https://github.com/nvm-sh/nvm) commands may be executed by using `nvm <command>`.
- [NPM](https://docs.npmjs.com/cli) commands may be executed by using `npm <command>`.
- [Artisan](https://laravel.com/docs/9.x/artisan) commands may be executed by using `php artisan <command>`.
- [Artisan](https://laravel.com/docs/10.x/artisan) commands may be executed by using `php artisan <command>`.

### Running tests

The project uses [Pest](http://pestphp.com) for testing. For more information about testing Laravel, [read the documentation](https://laravel.com/docs/9.x/testing).
The project uses [Pest](http://pestphp.com) for testing. For more information about testing Laravel, [read the documentation](https://laravel.com/docs/10.x/testing).

### Development workflow

Expand All @@ -260,18 +173,16 @@ The project uses [Pest](http://pestphp.com) for testing. For more information ab
- Feature development must take place in a fork, in a branch based on the `dev` branch. Feature branches
must be named according to the format `feat/<feature>`.
- Before opening a pull request, developers should run `composer format && composer analyze && composer test-coverage` to ensure that their code is properly formatted, does not cause static analysis errors, and passes tests. Depending on the code coverage, more tests may need to be written to ensure that code coverage does not drop.
- May need to enabled the XDEBUG coverage mode before running tests, for example `XDEBUG_MODE=coverage composer test-coverage`.
- May also want to run the tests in parallel to improve speed, for example `php artisan test --parallel` or `XDEBUG_MODE=coverage php artisan test --coverage --parallel`
- Once a feature is ready to merge into `dev`, the merge must be performed using a [squash commit](https://docs.github.com/en/github/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-pull-request-commits).
- The [`production`](https://github.com/accessibility-exchange/platform/tree/production) branch contains refined features that
are considered production-ready.
- The [`production`](https://github.com/accessibility-exchange/platform/tree/production) branch contains refined
features that are considered production-ready.
- Prereleases must be tagged from the `dev` branch.
- Releases must be tagged from the `production` branch.

### Working with markdown

In other Laravel applications you may see methods such as [`Str::markdown()`](https://laravel.com/docs/9.x/helpers#method-str-markdown)
and [`Str::inlineMarkdown()`](https://laravel.com/docs/9.x/helpers#method-str-inline-markdown) used. In general we attempt
In other Laravel applications you may see methods such as [`Str::markdown()`](https://laravel.com/docs/10.x/helpers#method-str-markdown)
and [`Str::inlineMarkdown()`](https://laravel.com/docs/10.x/helpers#method-str-inline-markdown) used. In general we attempt
to avoid using these methods and instead favour using the provided `safe_markdown()` and `safe_inlineMarkdown` helpers. These
methods will escape HTML used in a markdown string, strip unsafe links, and escape replacements. They are also tied into
the localization system, and will populate their strings into the string packages, just as `__()` would.
Expand All @@ -294,10 +205,10 @@ If you need to unescape a replacement you can use a `!` at the start of the plac

There are some cases where you may still wish to use the `Str` markdown helpers, such as when handling admin input (e.g.
resource collection information). In these special cases, make sure to call the Laravel markdown helpers with the
`SAFE_MARKDOWN_OPTIONS` argument to escape HTML and remove unsafe links.
`config('markdown')` argument to escape HTML and remove unsafe links.

```php
{!! Str::markdown('<em>Hello **World**</em>', SAFE_MARKDOWN_OPTIONS) !!}
{!! Str::markdown('<em>Hello **World**</em>', config('markdown')) !!}
{{-- <p>&lt;em&gt;Hello <strong>World</strong>&lt;/em&gt;</p> --}}
```

Expand All @@ -309,7 +220,7 @@ blade templates.

## Supported application environments

The application environment is set by specifying the `APP_ENV` environment variable. See [Environment Configuration](https://laravel.com/docs/9.x/configuration#environment-configuration) docs for more information.
The application environment is set by specifying the `APP_ENV` environment variable. See [Environment Configuration](https://laravel.com/docs/10.x/configuration#environment-configuration) docs for more information.

| `APP_ENV` | Description |
| --- | ---- |
Expand All @@ -318,7 +229,7 @@ The application environment is set by specifying the `APP_ENV` environment varia
| staging | For deploys from the "staging" branch. Used to test changes in a production like environment before going live. |
| production | For deploys from the "production" branch. The live production released code. |

Amongst other things, the application environment can be used to prevent tasks from running or requiring confirmation before running, e.g. in production running `php artisan migrate:fresh` requires confirmation. It can also be used to limit output in blade templates using the `@env()` or `@production` directives (See: [Environment Directives](https://laravel.com/docs/9.x/blade#environment-directives) docs)
Amongst other things, the application environment can be used to prevent tasks from running or requiring confirmation before running, e.g. in production running `php artisan migrate:fresh` requires confirmation. It can also be used to limit output in blade templates using the `@env()` or `@production` directives (See: [Environment Directives](https://laravel.com/docs/10.x/blade#environment-directives) docs)

## Custom Artisan Commands

Expand Down
6 changes: 3 additions & 3 deletions app/Console/Commands/SeederBackupData.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function handle()

return 0;

// restores backups
// restores backups
} elseif ($options['restore']) {
if (in_array(config('app.env'), ['testing', 'production']) === true) {
printf("This command cannot run on environment %s\r\n", config('app.env'));
Expand Down Expand Up @@ -111,7 +111,7 @@ public function handle()
return 0;
}

// default --all is to backup all tables
// default --all is to backup all tables
} elseif ($options['all']) {
foreach ($available_tables as $table) {
printf("Backing up table seeder: %s for environment: %s\r\n", $table, $environment);
Expand All @@ -120,7 +120,7 @@ public function handle()

return 0;

// if table is set the default will be to backup the table
// if table is set the default will be to backup the table
} elseif (count($options['table']) > 0) {
foreach ($options['table'] as $table) {
if (in_array($table, $available_tables)) {
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\URL;

use function localized_route;

class UserController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Kernel extends HttpKernel
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/AddEngagementConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AddEngagementConnector extends Component

public string $organization = '';

public function __invoke(Container $container, Route $route, ?Engagement $engagement = null)
public function __invoke(Container $container, Route $route, Engagement $engagement = null)
{
return parent::__invoke($container, $route);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/CollectionResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CollectionResources extends Component

protected $queryString = ['searchQuery' => ['except' => '', 'as' => 'search']];

public function __invoke(Container $container, Route $route, ?ResourceCollection $resourceCollection = null)
public function __invoke(Container $container, Route $route, ResourceCollection $resourceCollection = null)
{
return parent::__invoke($container, $route);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/ManageEngagementConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ManageEngagementConnector extends Component
'seeking_community_connector' => 'nullable|boolean',
];

public function __invoke(Container $container, Route $route, ?Engagement $engagement = null)
public function __invoke(Container $container, Route $route, Engagement $engagement = null)
{
return parent::__invoke($container, $route);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Course extends Model
{
use GeneratesMultilingualSlugs;
use HasFactory;
use HasTranslations;
use HasTranslatableSlug;
use HasTranslations;

protected $fillable = [
'title',
Expand Down
Loading