Skip to content
Open
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
68 changes: 48 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ references:
- APP_KEY: deela5kinohw0haekoothahSh8eexach

jobs:
"php-8.1-apache":
"php-8.2-apache":
docker:
- image: php:8.1-apache
- image: php:8.2-apache
environment: *environment
- *mysql
- *mariadb
Expand All @@ -86,9 +86,9 @@ jobs:
- *mariadb2
- *pgsql2
<<: *steps
"php-8.1-nginx":
"php-8.2-nginx":
docker:
- image: php:8.1-fpm
- image: php:8.2-fpm
environment: *environment
- *mysql
- *mariadb
Expand All @@ -97,21 +97,43 @@ jobs:
- *mariadb2
- *pgsql2
<<: *steps
"php-8.2-apache":
"php-8.3-apache":
docker:
- image: php:8.2-apache
environment: *environment
- image: php:8.3-apache
environment: *environment
- *mysql
- *mariadb
- *pgsql
- *mysql2
- *mariadb2
- *pgsql2
<<: *steps
"php-8.2-nginx":
"php-8.3-nginx":
docker:
- image: php:8.2-fpm
environment: *environment
- image: php:8.3-fpm
environment: *environment
- *mysql
- *mariadb
- *pgsql
- *mysql2
- *mariadb2
- *pgsql2
<<: *steps
"php-8.4-apache":
docker:
- image: php:8.4-apache
environment: *environment
- *mysql
- *mariadb
- *pgsql
- *mysql2
- *mariadb2
- *pgsql2
<<: *steps
"php-8.4-nginx":
docker:
- image: php:8.4-fpm
environment: *environment
- *mysql
- *mariadb
- *pgsql
Expand All @@ -121,7 +143,7 @@ jobs:
<<: *steps
coverage:
docker:
- image: php:8.1-fpm
- image: php:8.4-fpm
environment: *environment
- *mariadb
- *mariadb2
Expand Down Expand Up @@ -150,20 +172,26 @@ workflows:
version: 2
test:
jobs:
- "php-8.1-apache"
- "php-8.1-nginx":
- "php-8.2-apache"
- "php-8.2-nginx":
requires:
- "php-8.1-apache"
- "php-8.2-apache":
- "php-8.2-apache"
- "php-8.3-apache":
requires:
- "php-8.1-nginx"
- "php-8.2-nginx":
- "php-8.3-nginx"
- "php-8.3-nginx":
requires:
- "php-8.2-apache"
- "php-8.3-apache"
- "php-8.4-apache":
requires:
- "php-8.4-nginx"
- "php-8.4-nginx":
requires:
- "php-8.4-apache"
- coverage:
filters:
branches:
only: /^([0-9]+)\.x$/
requires:
- "php-8.1-apache"
- "php-8.1-nginx"
- "php-8.4-apache"
- "php-8.4-nginx"
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Dockerfile
FROM php:8.4-cli

# Installiere System-Abhängigkeiten
RUN apt-get update && apt-get install -y \
git \
zip \
unzip \
libzip-dev \
libicu-dev \
libonig-dev \
&& docker-php-ext-install zip pdo_mysql

# Composer installieren
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

# Arbeitsverzeichnis setzen
WORKDIR /var/www/html

# Projektdateien kopieren (optional; wenn du direkt via Volume mountest, ist dies evtl. nicht notwendig)
# COPY . /var/www/html

# Pakete installieren, Cache reduzieren
RUN composer global require "laravel/installer"

# Pfad zu Composer bin hinzufügen
ENV PATH="/root/.composer/vendor/bin:${PATH}"

# Standardkommando: Zeigt nur PHP-Version an (placeholder)
CMD ["php", "-v"]
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
"docs": "https://tenancy.dev"
},
"require": {
"php": "^8.0",
"doctrine/dbal": "~2.5|~3.0",
"php": "^8.2",
"ramsey/uuid": "^4.0",
"laravel/framework": "^9.0|^10.0"
"laravel/framework": "^12.0",
"doctrine/dbal": "^3.9"
},
"require-dev": {
"fakerphp/faker": "^1.12",
"laravel/laravel": "^9.0|^10.0",
"laravel/laravel": "^12.0",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^11.0",
"symfony/dom-crawler": "~3.1"
},
"autoload": {
Expand Down
25 changes: 25 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
mysql:
image: 'mysql:8.0'
ports:
- '3306:3306'
environment:
MYSQL_DATABASE: 'tenancy'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
command: --default-authentication-plugin=mysql_native_password
app:
build:
context: .
dockerfile: Dockerfile
container_name: hyn_app
working_dir: /var/www/html
volumes:
- .:/var/www/html
depends_on:
- mysql

command: >
bash -c "composer install
&& vendor/bin/phpunit"
volumes:
db_data:
6 changes: 5 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_DEBUG" value="true"/>
<env name="LOG_CHANNEL" value="stack"/>
<env name="APP_KEY" value="Phei9thoong3ai8aqu4ieHie6kee1zee"/>
<env name="DB_DATABASE" value="tenancy"/>
<env name="DB_PASSWORD" value=""/>
<env name="DB_CONNECTION" value="mysql"/>
<env name="DB_HOST" value="mysql"/>
<env name="DB_USERNAME" value="root"/>
<env name="MAIL_MAILER" value="log"/>
<env name="LIMIT_UUID_LENGTH_32" value="1"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="TENANCY_DATABASE_AUTO_DELETE" value="1"/>
<env name="TENANCY_DATABASE_AUTO_DELETE_USER" value="1"/>
<env name="TENANCY_DEFAULT_HOSTNAME" value="local.testing"/>
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Database separation methods:

## Requirements, recommended environment

- Laravel 9.0+.
- PHP 8.0+
- Laravel 12.0+.
- PHP 8.2+
- Apache or Nginx.
- MySQL, MariaDB, or PostgreSQL.

Expand Down
2 changes: 1 addition & 1 deletion src/Abstracts/AbstractTenantDirectoryListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected function path()
return $this->directory->path($this->path);
}

protected function directory(Website $website = null): Directory
protected function directory(?Website $website = null): Directory
{
/** @var Directory $directory */
$directory = app(Directory::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Abstracts/DatabaseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class DatabaseEvent extends AbstractEvent
*/
public $config;

public function __construct(array &$config, Website $website = null)
public function __construct(array &$config, ?Website $website = null)
{
$this->config = &$config;
$this->website = &$website;
Expand Down
2 changes: 1 addition & 1 deletion src/Abstracts/HostnameEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class HostnameEvent extends AbstractEvent
*/
public $hostname;

public function __construct(Hostname &$hostname = null)
public function __construct(?Hostname &$hostname = null)
{
$this->hostname = &$hostname;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Abstracts/WebsiteEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class WebsiteEvent extends AbstractEvent
*/
public $hostname;

public function __construct(Website &$website, Hostname $hostname = null)
public function __construct(?Website &$website, ?Hostname $hostname = null)
{
$this->website = &$website;
$this->hostname = $hostname;
Expand Down
8 changes: 4 additions & 4 deletions src/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function get(): \Illuminate\Database\Connection
* @param string|null $connection
* @return bool
*/
public function exists(string $connection = null): bool
public function exists(?string $connection = null): bool
{
$connection = $connection ?? $this->tenantName();

Expand Down Expand Up @@ -178,7 +178,7 @@ public function set($to, $connection = null): bool
return true;
}

public function configuration(string $connection = null): array
public function configuration(?string $connection = null): array
{
$connection = $connection ?? $this->tenantName();

Expand Down Expand Up @@ -244,7 +244,7 @@ public function purge($connection = null)
* @param string|null $path
* @return bool
*/
public function migrate($for, string $path = null): bool
public function migrate($for, ?string $path = null): bool
{
$website = $this->convertWebsiteOrHostnameToWebsite($for);

Expand Down Expand Up @@ -273,7 +273,7 @@ public function migrate($for, string $path = null): bool
* @param string $class
* @return bool
*/
public function seed($for, string $class = null): bool
public function seed($for, ?string $class = null): bool
{
$website = $this->convertWebsiteOrHostnameToWebsite($for);

Expand Down
6 changes: 4 additions & 2 deletions src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public function identifyHostname()

return $hostname;
});
// needed, does not work without it in laravel 12, but does in 10 (don't know why)
$this->app->make(CurrentHostname::class);
}

/**
Expand All @@ -91,7 +93,7 @@ public function identifyHostname()
* @param Hostname|null $hostname
* @return Hostname|null
*/
public function hostname(Hostname $hostname = null): ?Hostname
public function hostname(?Hostname $hostname = null): ?Hostname
{
if ($hostname !== null) {
$this->app->instance(CurrentHostname::class, $hostname);
Expand All @@ -117,7 +119,7 @@ public function website(): ?Website
* @param Website|null $website
* @return Tenant|null
*/
public function tenant(Website $website = null): ?Website
public function tenant(?Website $website = null): ?Website
{
if ($website !== null) {
$this->app->instance(Tenant::class, $website);
Expand Down
2 changes: 1 addition & 1 deletion src/Events/Database/ConnectionSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ConnectionSet extends AbstractEvent
*/
public $purged;

public function __construct(Website $website = null, string $connection, bool $purged = true)
public function __construct(?Website $website = null, string $connection, bool $purged = true)
{
$this->website = $website;
$this->connection = $connection;
Expand Down
2 changes: 1 addition & 1 deletion src/Events/Hostnames/Updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Updated extends HostnameEvent
*/
public $dirty;

public function __construct(Hostname $hostname = null, array $dirty = [])
public function __construct(?Hostname $hostname = null, array $dirty = [])
{
parent::__construct($hostname);

Expand Down
2 changes: 1 addition & 1 deletion src/Events/Websites/NoneFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class NoneFound extends AbstractEvent
* NoneFound constructor.
* @param Request $request
*/
public function __construct(Request $request = null)
public function __construct(?Request $request = null)
{
$this->request = $request;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/Tenants/QueueProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function boot()
{
$this->app->booted(function () {
$this->app->extend('queue', function (QueueManager $queue) {
$queue->createPayloadUsing(function (string $connection, string $queue = null, array $payload = []) {
$queue->createPayloadUsing(function (string $connection, ?string $queue = null, array $payload = []) {
/** @var Environment $environment */
$environment = resolve(Environment::class);

Expand Down
2 changes: 1 addition & 1 deletion src/Traits/DispatchesJobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ trait DispatchesJobs
*/
public function dispatch($command, $handler = null)
{
return app(Dispatcher::class)->dispatchNow($command, $handler);
return app(Dispatcher::class)->dispatchSync($command, $handler);
}
}
Loading