You've already forked Php-Template
Compare commits
5 Commits
54c656551e
...
v1.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
54ea22c49a
|
|||
|
f8d3462cb7
|
|||
|
68614958a9
|
|||
|
413145f479
|
|||
|
d2bd9d2d1b
|
@@ -1,2 +1,5 @@
|
||||
.idea/
|
||||
.DS_Store
|
||||
vendor/
|
||||
.phpunit.cache/
|
||||
tests/
|
||||
@@ -246,10 +246,23 @@ jobs:
|
||||
siteworxpro/composer \
|
||||
install --ignore-platform-reqs --no-interaction --prefer-dist --optimize-autoloader
|
||||
|
||||
- name: Run Unit Tests
|
||||
- name: 🧪 ✅ Run Unit Tests
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
image: siteworxpro/composer
|
||||
options: --volumes-from ${{ env.JOB_CONTAINER_NAME }} -w ${{ gitea.workspace }}
|
||||
run: |
|
||||
docker run --rm \
|
||||
--volumes-from ${{ env.JOB_CONTAINER_NAME }} \
|
||||
-w ${{ github.workspace }} \
|
||||
siteworxpro/composer \
|
||||
run tests:unit
|
||||
bin/pcov.sh
|
||||
composer run tests:unit:coverage
|
||||
|
||||
# - name: 📦 Publish Build Artifacts
|
||||
# env:
|
||||
# NODE_TLS_REJECT_UNAUTHORIZED: 0
|
||||
# uses: christopherhx/gitea-upload-artifact@v4
|
||||
# with:
|
||||
# options: --volumes-from ${{ env.JOB_CONTAINER_NAME }} -w ${{ gitea.workspace }}
|
||||
# name: junit-coverage.xml
|
||||
# path: tests/reports/junit.xml
|
||||
# retention-days: 1
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
||||
.idea/
|
||||
.DS_Store
|
||||
vendor/
|
||||
.phpunit.cache/
|
||||
|
||||
tests/reports/
|
||||
@@ -1,5 +0,0 @@
|
||||
include:
|
||||
- local: .gitlab/ci/stages.yml
|
||||
- local: .gitlab/ci/tests.yml
|
||||
- local: .gitlab/ci/libraries.yml
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
Install Composer Libraries:
|
||||
stage: libraries
|
||||
image: siteworxpro/composer:latest
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
when: never
|
||||
- if: '$CI_PIPELINE_SOURCE == "push"'
|
||||
when: always
|
||||
- when: never
|
||||
script:
|
||||
- composer install --ignore-platform-reqs
|
||||
artifacts:
|
||||
paths:
|
||||
- vendor/
|
||||
expire_in: 1 hour
|
||||
@@ -1,3 +0,0 @@
|
||||
stages:
|
||||
- libraries
|
||||
- tests
|
||||
@@ -1,65 +0,0 @@
|
||||
Unit Tests:
|
||||
stage: tests
|
||||
needs:
|
||||
- Install Composer Libraries
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
when: never
|
||||
- if: '$CI_PIPELINE_SOURCE == "push"'
|
||||
when: always
|
||||
- when: never
|
||||
image: siteworxpro/composer
|
||||
before_script: |
|
||||
bin/pcov.sh
|
||||
script: |
|
||||
echo "Running unit tests..."
|
||||
composer run tests:unit:coverage
|
||||
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
|
||||
artifacts:
|
||||
expire_in: 1 day
|
||||
reports:
|
||||
junit: tests/reports/junit.xml
|
||||
paths:
|
||||
- tests/reports/
|
||||
|
||||
Run License Check:
|
||||
stage: tests
|
||||
needs:
|
||||
- Install Composer Libraries
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
when: never
|
||||
- if: '$CI_PIPELINE_SOURCE == "push"'
|
||||
when: on_success
|
||||
- when: never
|
||||
image: siteworxpro/composer
|
||||
script:
|
||||
- composer run tests:license
|
||||
|
||||
Run Code Lint:
|
||||
stage: tests
|
||||
needs:
|
||||
- Install Composer Libraries
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
when: never
|
||||
- if: '$CI_PIPELINE_SOURCE == "push"'
|
||||
when: on_success
|
||||
- when: never
|
||||
image: siteworxpro/composer
|
||||
script:
|
||||
- composer run tests:lint
|
||||
|
||||
Run Code Sniffer:
|
||||
stage: tests
|
||||
needs:
|
||||
- Install Composer Libraries
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
when: never
|
||||
- if: '$CI_PIPELINE_SOURCE == "push"'
|
||||
when: on_success
|
||||
- when: never
|
||||
image: siteworxpro/composer
|
||||
script:
|
||||
- composer run tests:phpstan
|
||||
@@ -1,5 +1,5 @@
|
||||
# Use the RoadRunner image as a base for the first stage
|
||||
FROM ghcr.io/roadrunner-server/roadrunner:2025.1.1 AS roadrunner
|
||||
FROM ghcr.io/roadrunner-server/roadrunner:2025.1.4 AS roadrunner
|
||||
|
||||
# Use the official Composer image as the base for the library stage
|
||||
FROM siteworxpro/composer AS library
|
||||
@@ -12,7 +12,7 @@ RUN composer install --optimize-autoloader --ignore-platform-reqs --no-dev
|
||||
|
||||
|
||||
# Use the official PHP CLI image with Alpine Linux for the second stage
|
||||
FROM php:8.4.6-alpine AS php
|
||||
FROM php:8.4.14-alpine AS php
|
||||
|
||||
# Move the production PHP configuration file to the default location
|
||||
RUN mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini \
|
||||
|
||||
4
bin/migrate.sh
Executable file
4
bin/migrate.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
eval #!/bin/sh
|
||||
set -e
|
||||
|
||||
migrate -path /app/db/migrations -database "postgres://$DB_USERNAME:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_DATABASE?sslmode=disable" up
|
||||
@@ -12,6 +12,24 @@ services:
|
||||
environment:
|
||||
PHP_IDE_CONFIG: serverName=localhost
|
||||
|
||||
migration-container:
|
||||
volumes:
|
||||
- ./db/migrations:/app/db/migrations
|
||||
- ./bin:/app/bin
|
||||
image: siteworxpro/migrate:v4.18.3
|
||||
working_dir: /app
|
||||
# entrypoint: "/bin/sh -c 'while true; do sleep 30; done;'"
|
||||
entrypoint: /bin/sh -c '/app/bin/migrate.sh'
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
DB_USERNAME: ${DB_USERNAME:-siteworxpro}
|
||||
DB_PASSWORD: ${DB_PASSWORD:-password}
|
||||
DB_DATABASE: ${DB_DATABASE:-siteworxpro}
|
||||
DB_HOST: ${DB_HOST-postgres}
|
||||
DB_PORT: ${DB_PORT-5432}
|
||||
|
||||
dev-runtime:
|
||||
ports:
|
||||
- "9501:9501"
|
||||
@@ -29,6 +47,11 @@ services:
|
||||
|
||||
redis:
|
||||
image: redis:latest
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
@@ -36,6 +59,11 @@ services:
|
||||
|
||||
postgres:
|
||||
image: postgres:latest
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME:-siteworxpro}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
environment:
|
||||
POSTGRES_USER: ${DB_USERNAME:-siteworxpro}
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD:-password}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
FROM siteworxpro/migrate:v4.18.3
|
||||
|
||||
ADD db/migrations /app/db/migrations
|
||||
ADD bin/migrate.sh /app/bin/migrate.sh
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENTRYPOINT ["/app/bin/migrate.sh"]
|
||||
|
||||
@@ -6,6 +6,12 @@ namespace Siteworxpro\App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model as ORM;
|
||||
|
||||
/**
|
||||
* Class Model
|
||||
*
|
||||
* @package Siteworxpro\App\Models
|
||||
*/
|
||||
abstract class Model extends ORM
|
||||
{
|
||||
protected $dateFormat = 'Y-m-d H:i:s';
|
||||
}
|
||||
|
||||
52
src/Models/User.php
Normal file
52
src/Models/User.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*
|
||||
* @property string $id
|
||||
* @property string $first_name
|
||||
* @property string $last_name
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property Carbon $created_at
|
||||
*
|
||||
* @property-read string $full_name
|
||||
* @property-read string $formatted_email
|
||||
*/
|
||||
class User extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
public function getFullNameAttribute(): string
|
||||
{
|
||||
return "$this->first_name $this->last_name";
|
||||
}
|
||||
|
||||
public function getFormattedEmailAttribute(): string
|
||||
{
|
||||
return sprintf(
|
||||
'%s <%s>',
|
||||
$this->getFullNameAttribute(),
|
||||
strtolower($this->email)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,6 @@ class ControllerTest extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
// @ignore
|
||||
class TestClass extends Controller
|
||||
class TestClass extends Controller // phpcs:ignore
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ use Siteworxpro\Tests\Unit;
|
||||
|
||||
abstract class AbstractServiceProvider extends Unit
|
||||
{
|
||||
|
||||
abstract protected function getProviderClass(): string;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user