Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
72 changes: 55 additions & 17 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,74 @@ permissions:
contents: read

jobs:
test-phpunit:

test-phpunit-matrix:
name: test-phpunit (${{ matrix.database }})
runs-on: ubuntu-latest
strategy:
matrix:
database: [sqlite, mysql]
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: testing
MYSQL_DATABASE: testing
ports:
- 3306/tcp
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -ptesting"
--health-interval=10s
--health-timeout=5s
--health-retries=10

steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.1'
- uses: actions/checkout@v4

- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: bcmath, intl, mbstring, pdo_mysql, pdo_sqlite
coverage: none

- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"

- name: Install Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Install dependencies
run: composer install --no-ansi --no-interaction --no-progress --prefer-dist

- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Execute tests
env:
DB_CONNECTION: ${{ matrix.database }}
DB_DATABASE: ${{ matrix.database == 'sqlite' && ':memory:' || 'testing' }}
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
DB_USERNAME: root
DB_PASSWORD: testing
run: composer test

- uses: actions/setup-node@v4
if: matrix.database == 'sqlite'
with:
node-version: '22'
cache: npm

- name: Create Database
- name: Build frontend assets
if: matrix.database == 'sqlite'
run: |
mkdir -p database
touch database/database.sqlite
npm ci
npm run build

- name: Execute tests (Unit and Feature tests) via PHPUnit
test-phpunit:
runs-on: ubuntu-latest
needs: test-phpunit-matrix
if: ${{ always() }}
steps:
- name: Require all database tests to pass
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: composer test
TEST_RESULT: ${{ needs.test-phpunit-matrix.result }}
run: |
echo "Database tests: $TEST_RESULT"
test "$TEST_RESULT" = success
14 changes: 10 additions & 4 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
extensions: bcmath, intl, mbstring
coverage: none

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-php-8.5-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
${{ runner.os }}-php-8.5-

- name: Install dependencies
run: composer install --prefer-dist --no-progress
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ yarn-error.log
/.phpstorm.meta.php
/build
.DS_Store

.phpunit.cache/
19 changes: 9 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
FROM php:8.1-cli-alpine AS composer_base
FROM node:22-alpine AS vite_base
WORKDIR /var/www/html

COPY --from=composer /usr/bin/composer /usr/bin/composer



FROM node:19-alpine AS vite_base
FROM php:8.5-fpm-alpine AS php_base
WORKDIR /var/www/html

RUN apk add --no-cache icu-libs libzip oniguruma
RUN apk add --no-cache --virtual .php-build-deps icu-dev libzip-dev oniguruma-dev \
&& docker-php-ext-install pdo_mysql intl mbstring zip \
&& apk del .php-build-deps

COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini

FROM php:8.1-fpm-alpine AS php_base
WORKDIR /var/www/html

RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-install opcache
FROM php_base AS composer_base
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini



Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# WebPrint Server

The application runs on **PHP 8.5**, **Laravel 13**, **Jetstream 5**, and **Livewire 3**.

## Development

Use Composer 2, Node.js 22.12 or newer, and MySQL 8.0. PHP needs the usual Laravel extensions, PDO MySQL, `mbstring`, and `intl`; development dependencies also require `bcmath`. SQLite is supported for tests.

```sh
cp .env.example .env
composer install
php artisan key:generate
php artisan migrate
npm ci
npm run build
```

Laravel Sail uses PHP 8.5. Keep the existing `.env` values when upgrading an installation.

## Upgrading an existing installation

Back up the database and `storage/app/jobs`, and preserve the existing `APP_KEY`. Deploy the updated PHP code, Composer dependencies, and frontend assets together. All PHP services (FPM and cron) must use the new images.

```sh
php artisan optimize:clear
php artisan migrate --force
```

The new settings migration upgrades the existing table for `spatie/laravel-settings` 3: it adds a unique index on `(group, name)` and defaults `locked` to false. Existing setting values and lock states are retained. Resolve duplicate `(group, name)` records before migrating if the database contains any.

The Docker build script installs production dependencies, compiles the views, and builds the frontend assets. It no longer bypasses Composer platform requirements. Livewire 3 discovers components without the old `livewire:discover` command and supplies Alpine.js itself.

## Verification

```sh
composer validate --strict
composer test
composer test-pint
npm run build
```

Tests default to an in-memory SQLite database. To include JSON query scenarios that require MySQL, use a separate disposable test database:

```sh
DB_CONNECTION=mysql DB_DATABASE=testing DB_USERNAME=root DB_PASSWORD=testing composer test
```

CI runs the suite on PHP 8.5 with both SQLite and MySQL 8.0. The suite covers the printing APIs, bearer tokens, team permissions, panel components, settings migration, and scheduled print cleanup.
2 changes: 1 addition & 1 deletion app/Actions/Apps/CreateAppAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CreateAppAction
{
public function handle(Team $team, string $name): ClientApplication
{
$app = new ClientApplication();
$app = new ClientApplication;
$app->name = $name;
$app->team_id = $team->id;
$app->save();
Expand Down
3 changes: 1 addition & 2 deletions app/Actions/Apps/DeleteAppAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class DeleteAppAction
public function __construct(
protected DeleteJobAction $deleteJobAction,
protected DeletePromiseAction $deletePromiseAction,
) {
}
) {}

public function handle(ClientApplication $app): void
{
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CreateNewUser implements CreatesNewUsers
/**
* Create a newly registered user.
*
* @return \App\Models\User
* @return User
*/
public function create(array $input)
{
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Fortify/PasswordValidationRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ trait PasswordValidationRules
*/
protected function passwordRules(): array
{
return ['required', 'string', new Password(), 'confirmed'];
return ['required', 'string', new Password, 'confirmed'];
}
}
5 changes: 2 additions & 3 deletions app/Actions/Jetstream/AddTeamMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class AddTeamMember implements AddsTeamMembers
*
* @param mixed $user
* @param mixed $team
* @param string|null $role
*/
public function add($user, $team, string $email, string $role = null): void
public function add($user, $team, string $email, ?string $role = null): void
{
Gate::forUser($user)->authorize('addTeamMember', $team);

Expand Down Expand Up @@ -62,7 +61,7 @@ protected function rules(): array
return array_filter([
'email' => ['required', 'email', 'exists:users'],
'role' => Jetstream::hasRoles()
? ['required', 'string', new Role()]
? ['required', 'string', new Role]
: null,
]);
}
Expand Down
3 changes: 1 addition & 2 deletions app/Actions/Jetstream/DeleteTeam.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class DeleteTeam implements DeletesTeams
public function __construct(
protected DeleteServerAction $deleteServerAction,
protected DeleteAppAction $deleteAppAction,
) {
}
) {}

/**
* Delete the given team.
Expand Down
3 changes: 1 addition & 2 deletions app/Actions/Jetstream/DeleteUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public function __construct(
* The team deleter implementation.
*/
protected DeletesTeams $deletesTeams
) {
}
) {}

/**
* Delete the given user.
Expand Down
5 changes: 2 additions & 3 deletions app/Actions/Jetstream/InviteTeamMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ class InviteTeamMember implements InvitesTeamMembers
*
* @param mixed $user
* @param mixed $team
* @param string|null $role
*/
public function invite($user, $team, string $email, string $role = null): void
public function invite($user, $team, string $email, ?string $role = null): void
{
Gate::forUser($user)->authorize('addTeamMember', $team);

Expand Down Expand Up @@ -64,7 +63,7 @@ protected function rules(mixed $team): array
$query->where('team_id', $team->id);
})],
'role' => Jetstream::hasRoles()
? ['required', 'string', new Role()]
? ['required', 'string', new Role]
: null,
]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Jetstream/RemoveTeamMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function authorize(mixed $user, mixed $team, mixed $teamMember)
{
if (! Gate::forUser($user)->check('removeTeamMember', $team) &&
$user->id !== $teamMember->id) {
throw new AuthorizationException();
throw new AuthorizationException;
}
}

Expand Down
3 changes: 1 addition & 2 deletions app/Actions/Jobs/DeleteJobAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class DeleteJobAction
public function __construct(
protected DeletePromiseAction $deletePromiseAction,
protected ClearJobContentAction $clearJobContentAction,
) {
}
) {}

public function handle(PrintJob $job): void
{
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Printers/CreatePrinterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CreatePrinterAction
{
public function handle(PrintServer $server, string $name, string $uri = '', array $languages = []): Printer
{
$printer = new Printer();
$printer = new Printer;
$printer->name = $name;
$printer->print_server_id = $server->id;
$printer->raw_languages_supported = $languages;
Expand Down
3 changes: 1 addition & 2 deletions app/Actions/Printers/DeletePrinterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class DeletePrinterAction
public function __construct(
protected DeleteJobAction $deleteJobAction,
protected DeletePromiseAction $deletePromiseAction,
) {
}
) {}

public function handle(Printer $printer): void
{
Expand Down
5 changes: 2 additions & 3 deletions app/Actions/Promises/ConvertPromiseToJobAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ class ConvertPromiseToJobAction
{
public function __construct(
protected CheckPromiseAbilityToBePrintedAction $checkPromiseAbilityToBePrintedAction,
) {
}
) {}

public function handle(PrintJobPromise $promise): ?PrintJob
{
if (! $this->checkPromiseAbilityToBePrintedAction->handle($promise)) {
return null;
}

$job = new PrintJob();
$job = new PrintJob;
$job->client_application_id = $promise->client_application_id;
$job->printer_id = $promise->printer_id;
$job->name = $promise->name;
Expand Down
3 changes: 1 addition & 2 deletions app/Actions/Promises/DeletePromiseAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class DeletePromiseAction
{
public function __construct(
protected ClearPromiseContentAction $clearPromiseContentAction,
) {
}
) {}

public function handle(PrintJobPromise $printer): void
{
Expand Down
Loading
Loading