Skip to content

Commit

Permalink
Update to Laravel 11
Browse files Browse the repository at this point in the history
This is a jump from Laravel 4.2 to Laravel 11. I've tested
a lot of functionality, but there's likely more things that
need some adjustments.

I've based this on going through all upgrade guides, comparing it
against a clean installation and comparing it against the state
of the "intern" repo.

simplesamlphp is replaced by onelogin/php-saml similar as in
the "intern" repo.

Update to PHP 8.3.

Simplify the dev setup, dropping the docker-only dev workflow
to reduce complexity.

The database will be manually changed to use utf8mb4.
  • Loading branch information
henrist committed Jul 10, 2024
1 parent 5d8ac43 commit 79d6608
Show file tree
Hide file tree
Showing 167 changed files with 9,369 additions and 4,438 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.php]
indent_size = 4
[*.md]
trim_trailing_whitespace = false
59 changes: 17 additions & 42 deletions Dockerfile.fpm
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
FROM php:5.6-fpm
MAINTAINER Henrik Steen <[email protected]>

ENV SIMPLESAMLPHP_VERSION 1.14.7
ENV SIMPLESAMLPHP_SHA256 a7a24d4dc89819f7e53141b38ae36b092a5c1fc9cb2e3cee253c765e5942be52
FROM php:8.3-fpm

RUN \
# system packages
apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
git \
gosu \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
unzip \
wget \
&& rm -rf /var/lib/apt/lists/* \
\
# php extensions
&& docker-php-ext-install -j$(nproc) mcrypt pdo_mysql \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include --with-jpeg-dir=/usr/include \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install pdo_mysql gd \
\
# set up composer
&& EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) \
Expand All @@ -36,14 +28,6 @@ RUN \
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer --quiet \
&& rm composer-setup.php \
\
# simplesamlphp
&& mkdir /var/simplesamlphp \
&& cd /var/simplesamlphp \
&& curl -fSL "https://github.com/simplesamlphp/simplesamlphp/releases/download/v$SIMPLESAMLPHP_VERSION/simplesamlphp-$SIMPLESAMLPHP_VERSION.tar.gz" -o simplesamlphp.tar.gz \
&& echo "$SIMPLESAMLPHP_SHA256 *simplesamlphp.tar.gz" | sha256sum -c - \
&& tar --strip-components=1 -zxf simplesamlphp.tar.gz \
&& rm simplesamlphp.tar.gz \
\
# billett
&& mkdir -p /var/billett/cache \
&& mkdir -p /var/billett/logs \
Expand All @@ -52,43 +36,34 @@ RUN \
&& mkdir -p /var/billett/views \
&& chown -R www-data:www-data /var/billett /var/www /var/www/html

# configure simplesamlphp
COPY simplesamlphp/config.override.php /var/simplesamlphp/config/
COPY simplesamlphp/authsources.php /var/simplesamlphp/config/
COPY simplesamlphp/saml20-idp-remote.php /var/simplesamlphp/metadata/
RUN cd /var/simplesamlphp && tail -n +2 config/config.override.php >>config/config.php
COPY --chown=www-data:www-data backend/composer.* /var/www/html/

COPY backend/composer.* /var/www/html/
USER www-data

# create directories that are scanned on composer install
# this is later replaced with new source, but we need this
# here to have cache of composer modules to avoid cache miss
# in case only our code is updated and not dependencies
USER www-data
RUN mkdir -p app/commands \
app/controllers \
app/models \
app/database/migrations \
app/database/seeds \
app/tests \
app/src \
&& echo -e '#!/usr/bin/env php\n<?php' >artisan \
&& echo -e '#!/usr/bin/env php\n<?php' >app/tests/TestCase.php \
&& chmod +x artisan \
&& composer install \
&& mv vendor /var/www/html-vendor \
&& ln -s /var/www/html-vendor /var/www/html/vendor
RUN set -eux; \
mkdir -p \
app/Console/Commands \
database \
tests \
; \
echo -e '#!/usr/bin/env php\n<?php' >artisan; \
echo -e '#!/usr/bin/env php\n<?php' >tests/TestCase.php; \
composer install; \
mv vendor /var/www/html-vendor; \
ln -s /var/www/html-vendor /var/www/html/vendor


COPY backend /var/www/html/
COPY --chown=www-data:www-data backend /var/www/html/

# we run composer install again so the post process commands
# are run
RUN composer install

USER root
COPY backend/container/entrypoint.sh /entrypoint.sh
COPY backend/container/dev.sh /dev.sh

VOLUME ["/var/billett"]
ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
22 changes: 0 additions & 22 deletions Makefile

This file was deleted.

27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ More documentation: [Documentation (norwegian)](docs/index.md)

This project is run with Docker and mainly consists of:

* PHP backend container running php-fpm serving the backend api as well as simplesamlphp for authentication
* PHP backend container running php-fpm serving the backend api
* nginx container that serves the static files and acts as a proxy to the backend
* mysql container as database

Docker Compose is used to simplify running the containers.

## Backend API details

The backend runs Laravel and provides only an API for the frontend. See the
Expand All @@ -35,22 +33,21 @@ docker exec -t uka-billett-fpm ./artisan migrate

## Development setup

### Running the backend
Docker Compose is used to simplify running the containers locally.

To ease development, see `Makefile`
### Running the backend

Normally all that is needed is to run:
```bash
docker compose up database
```

```bash
make dev
# to make it proxy for the frontend aswell
# you might need to run it like this (with the
# correct IP):
DOCKER_GATEWAY_HOST=172.18.0.1 make dev
cd backend
composer install
php artisan serve --port 8081
```

And the development environment should start and be available
at http://localhost:8081/
http://localhost:8081/

### Running the frontend

Expand All @@ -62,10 +59,10 @@ BACKEND_URL=https://billett.blindernuka.no/ npm run dev

Open http://localhost:3000/

## Running phpMyAdmin for development
### Running phpMyAdmin for development

```bash
docker-compose -f docker-compose.admin.yml up
docker compose up phpmyadmin
```

Now go to http://localhost:8080/
2 changes: 2 additions & 0 deletions backend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*]
indent_size = 4
7 changes: 7 additions & 0 deletions backend/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* text=auto eol=lf

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
class CleanOrders extends Command
{
/**
* The console command name.
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'billett:clean-orders';
protected $signature = 'billett:clean-orders';

/**
* The console command description.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

use Blindern\UKA\Billett\Order;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class SendOrderEmail extends Command
{
/**
* The console command name.
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'billett:sendorderemail';
protected $signature = 'billett:sendorderemail {id}';

/**
* The console command description.
Expand Down Expand Up @@ -42,28 +40,4 @@ public function fire()
$order->sendEmail();
echo 'Email should now have been sent to '.$order->email.' ('.$order->name.").\n";
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [
['id', InputArgument::REQUIRED, 'Order ID'],
];
}

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
//array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
];
}
}
6 changes: 6 additions & 0 deletions backend/app/Helpers/format.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

function format_nok($num)
{
return 'NOK '.number_format($num, 0, ',', ' ');
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace App\Http\Controllers;

use Blindern\UKA\Billett\Daytheme;
use Blindern\UKA\Billett\Helpers\ModelHelper;
use Illuminate\Routing\Controller;
Expand Down Expand Up @@ -50,8 +52,8 @@ private function validateInputAndUpdate(Daytheme $daytheme, $is_new)
{
$fields = [
'title' => '',
'eventgroup_id' => 'integer',
'date' => 'integer',
'eventgroup_id' => 'nullable|integer',
'date' => 'nullable|integer',
];

if ($is_new) {
Expand Down
Loading

0 comments on commit 79d6608

Please sign in to comment.