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

[FEATURE] Doctrine ORM 3.0 & DBAL 4.0 & Doctrine Coding Standard #582

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c40e73c
Upgrade to orm 3
TomHAnderson Sep 24, 2024
0ae7f7d
Correct getSQLDeclaration function declarations
TomHAnderson Sep 24, 2024
62e1826
Fixed function declarations for LaravelNamingStrategy
TomHAnderson Sep 24, 2024
4ef108e
tablesExist takes an array
TomHAnderson Sep 24, 2024
8f662cf
Send className to joinColumnName
TomHAnderson Sep 24, 2024
f40f0ec
Replaced all instances of annotations
TomHAnderson Sep 24, 2024
eb63332
Removed annotations from tests
TomHAnderson Sep 24, 2024
6b77cb5
Removed simplifiedyaml
TomHAnderson Sep 25, 2024
085c395
Removed YAML driver
TomHAnderson Sep 25, 2024
46326f3
Fixed no SQLFilter returned
TomHAnderson Sep 25, 2024
ea07093
Don't use XML driver class as a mockery
TomHAnderson Sep 25, 2024
9ad4551
Run of phpunit fixes
TomHAnderson Sep 25, 2024
372d133
Refactored FactoryBuilderTest
TomHAnderson Sep 25, 2024
6eed205
QueryBuilder tests skipped
TomHAnderson Sep 25, 2024
6627326
Revisited DoctrinePersistenceVerifierTest
TomHAnderson Sep 25, 2024
6195d6a
Fixed test_get_alias_namespace_from_unknown_namespace
TomHAnderson Sep 25, 2024
8ef8ced
Removed TablePrefixListener
TomHAnderson Sep 25, 2024
3cdf7f8
test_second_level_caching_can_be_enabled adjusted for mocked methods
TomHAnderson Sep 25, 2024
6fb5e3a
Fixed naming strategy
TomHAnderson Sep 25, 2024
9ed4d44
deleteExisting always returns int
TomHAnderson Sep 25, 2024
1e72961
Fixed paginator adapter test; field mappings are now objects
TomHAnderson Sep 25, 2024
0e48df0
Fixed faker data for DoctrinePresenceVerifier
TomHAnderson Sep 25, 2024
0d54abe
Update package versions; remove yaml
TomHAnderson Sep 26, 2024
b0a552b
Default to attributes metadata
TomHAnderson Sep 26, 2024
c23a8bd
Moved tests to Feature directory to make room for non-tests in tests dir
TomHAnderson Sep 29, 2024
7f34b09
Use dir in tests for custom path test
TomHAnderson Sep 29, 2024
8efc717
Use test path for doctrine-cache and cleanup afterwords
TomHAnderson Sep 29, 2024
899ea96
Added Doctrine Coding Standard to src
TomHAnderson Sep 29, 2024
16409cc
phpunit passing
TomHAnderson Sep 30, 2024
a321c39
Added test script to composer
TomHAnderson Sep 30, 2024
873e6be
Added self to project
TomHAnderson Sep 30, 2024
256e9b5
Added php-parallel-lint
TomHAnderson Sep 30, 2024
4dd88ca
Removed doctrine/cache
TomHAnderson Sep 30, 2024
50f6bd1
Added coverage script to composer.json
TomHAnderson Sep 30, 2024
12699ec
Added coding standards workflow
TomHAnderson Oct 3, 2024
a3fe0eb
Copied continuous integration from doctrine-orm-graphql
TomHAnderson Oct 3, 2024
4e65814
Removed old CI workflow
TomHAnderson Oct 3, 2024
d5b54bb
Dropped support for Laravel 9
TomHAnderson Oct 3, 2024
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
31 changes: 0 additions & 31 deletions .github/workflows/ci.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Coding Standards"

on:
pull_request:
branches:
- "*.x"
- "main"
push:
branches:
- "*.x"
- "main"

jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/[email protected]"
with:
php-version: '8.1'
composer-options: '--prefer-dist --ignore-platform-req=php'

84 changes: 84 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: "Continuous Integration"

on:
pull_request:
branches:
- "*.x"
- "main"
push:
branches:
- "*.x"
- "main"

jobs:
phpunit:
name: "PHPUnit"
runs-on: "ubuntu-20.04"

strategy:
fail-fast: false
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
dependencies:
- "highest"
- "lowest"
optional-dependencies:
- true
- false

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
ini-values: "zend.assertions=1"
extensions: "pdo_mysql"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist"

- name: "Show Composer packages"
run: "composer show"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"

- name: "Upload coverage file"
uses: "codecov/codecov-action@v4"
with:
name: "phpunit-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ matrix.dbal-version }}.coverage"
files: "./coverage.xml"

upload_coverage:
name: "Upload coverage to Codecov"
runs-on: "ubuntu-20.04"
needs:
- "phpunit"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Download coverage files"
uses: "actions/download-artifact@v4"
with:
path: "reports"

- name: "Upload to Codecov"
uses: "codecov/codecov-action@v2"
with:
directory: "reports"
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/coverage
/vendor
composer.phar
composer.lock
.DS_Store
.php_cs.cache
.php-cs-fixer.cache
.phpcs-cache
.phpunit.result.cache

/tests/Stubs/storage/framework/views/*
Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) 2015 Patrick Brouwers
Copyright (c) 2024 Tom H Anderson <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ EntityManager::flush();
* Pagination
* Pre-configured metadata, connections and caching
* Extendable: extend or add your own drivers for metadata, connections or cache
* Fluent, Annotations, YAML, SimplifiedYAML, XML, SimplifiedXML, Config and Static PHP metadata mappings
* Multiple entity managers and connections
* Laravel naming strategy
* Simple authentication implementation
Expand Down
54 changes: 36 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,43 @@
{
"name": "Patrick Brouwers",
"email": "[email protected]"
},
{
"name": "Tom H Anderson",
"email": "[email protected]"
}
],
"require": {
"php": "^8.0",
"doctrine/annotations": "^2",
"doctrine/dbal": "^3.2",
"doctrine/orm": "^2.14",
"doctrine/persistence": "^3",
"illuminate/auth": "^9.0|^10.0|^11.0",
"illuminate/console": "^9.0|^10.0|^11.0",
"illuminate/container": "^9.0|^10.0|^11.0",
"illuminate/contracts": "^9.0|^10.0|^11.0",
"illuminate/pagination": "^9.0|^10.0|^11.0",
"illuminate/routing": "^9.0|^10.0|^11.0",
"illuminate/support": "^9.0|^10.0|^11.0",
"illuminate/validation": "^9.0|^10.0|^11.0",
"illuminate/view": "^9.0|^10.0|^11.0",
"php": "^8.1",
"doctrine/dbal": "^4.1",
"doctrine/orm": "^3.1",
Comment on lines +24 to +25
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this is handled on this repository usually, but it might be smart to create releases that support ORM 2 and 3 first, so people can migrate one package at a time. Same for DBAL.

Copy link
Contributor Author

@TomHAnderson TomHAnderson Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ORM 3 requires DBAL 4. What my PR proposes is a major version release without a path to migrate "gracefully".

This library is sorely lacking support for the latest Doctrine libraries. If version 2 of this library still works for folks, that's fine. But constant progress on this library is non-existent. It's like the whole team (10 of you?) has dropped their assumed goal of maintaining a world-class library.

It's not uncommon for older packages to lose traction after some time, but this library is the best solution to Doctrine ORM in Laravel and both those projects continue to mature.

Copy link
Member

@eigan eigan Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's like the whole team (10 of you?) has dropped their assumed goal of maintaining a world-class library.

Note that the Doctrine team is not related to this library. I have been the sole "maintainer" of this library for several years. But I almost never contribute myself, it's up to the community to provide pull requests, unless none have provided a pull request before laravel goes out of security updates.

Yes, laravel-doctrine needs a proper maintainer which can lift this package up to latest standard and keep constant progress.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this isn't you:
https://github.com/laravel-doctrine/orm/blob/2.0/LICENSE#L3
And this isn't you:
https://github.com/laravel-doctrine/orm/blob/2.0/composer.json#L14-L15

I would like to be that proper maintainer for this organization. I have many Doctrine ORM and Laravel libraries at https://github.com/api-skeletons I am also a member of the Doctrine open source team. My latest project, the LDOG Stack, https://github.com/api-skeletons/ldog, relies on this library as well as my other projects. Reviving this resource is in my best interest.

To see my latest work please review https://github.com/api-skeletons/doctrine-orm-graphql (and be sure to see the documentation).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont feel that I have contributed enough to this repo that I feel I should be on those lists.. :)

I will take a look at your profile. I don't think it will be any problem of giving you access 👌

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ORM 3 requires DBAL 4.

It does not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see in this composer.json, libraries can be compatible with both ORM 2 and 3 and DBAL 3 and 4.
https://github.com/API-Skeletons/doctrine-orm-graphql/blob/12.2.x/composer.json#L14-L22

I don't foresee version 3 of this library trying to do the same. So I think to catch this library up, ORM 3 should be supported at the highest versions.

"doctrine/persistence": "^3.3",
"illuminate/auth": "^10.0|^11.0",
"illuminate/console": "^10.0|^11.0",
"illuminate/container": "^10.0|^11.0",
"illuminate/contracts": "^10.0|^11.0",
"illuminate/pagination": "^10.0|^11.0",
"illuminate/routing": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"illuminate/validation": "^10.0|^11.0",
"illuminate/view": "^10.0|^11.0",
"symfony/cache": "^6.0|^7.0",
"symfony/serializer": "^5.0|^6.0|^7.0",
"symfony/yaml": "^5.0|^6.0|^7.0"
"symfony/serializer": "^5.0|^6.0|^7.0"
},
"conflict": {
"laravel/lumen": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"mockery/mockery": "^1.3.1",
"mockery/mockery": "^1.6.12",
"illuminate/log": "^9.0|^10.0|^11.0",
"illuminate/notifications": "^9.0|^10.0|^11.0",
"illuminate/queue": "^9.0|^10.0|^11.0",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-deprecation-rules": "^1.1"
"phpstan/phpstan-deprecation-rules": "^1.1",
"doctrine/coding-standard": "^12.0",
"php-parallel-lint/php-parallel-lint": "^1.4",
"vimeo/psalm": "^0.3.14"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -78,5 +83,18 @@
"EntityManager": "LaravelDoctrine\\ORM\\Facades\\EntityManager"
}
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
"test": [
"vendor/bin/parallel-lint src tests",
"vendor/bin/phpcs",
"vendor/bin/phpunit"
],
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage"
}
}
2 changes: 1 addition & 1 deletion config/doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'managers' => [
'default' => [
'dev' => env('APP_DEBUG', false),
'meta' => env('DOCTRINE_METADATA', 'annotations'),
'meta' => env('DOCTRINE_METADATA', 'attributes'),
'connection' => env('DB_CONNECTION', 'mysql'),
'paths' => [
base_path('app/Entities')
Expand Down
17 changes: 17 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>

<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>

<!-- Directories to be checked -->
<file>src</file>

<!-- Include full Doctrine Coding Standard -->
<rule ref="Doctrine"/>
</ruleset>
48 changes: 11 additions & 37 deletions src/AbstractTable.php
Original file line number Diff line number Diff line change
@@ -1,73 +1,47 @@
<?php

declare(strict_types=1);

namespace LaravelDoctrine\ORM;

use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;

/** @interal */
// phpcs:disable SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix
abstract class AbstractTable
{
/**
* @var string
*/
protected string $table;

/**
* @param string $table
*/
public function __construct(string $table)
public function __construct(protected string $table)
{
$this->table = $table;
}

/**
* @return Table
*/
public function build(): Table
{
return new Table(
$this->table,
$this->columns(),
$this->indices()
$this->indices(),
);
}

/**
* @param string $name
* @param string $type
* @param bool $autoincrement
* @return Column
*/
protected function column($name, string $type, bool $autoincrement = false): Column
protected function column(string $name, string $type, bool $autoincrement = false): Column
{
$column = new Column($name, Type::getType($type));
$column->setAutoincrement($autoincrement);

return $column;
}

/**
* @param string $name
* @param string[] $columns
* @param bool $unique
* @param bool $primary
* @return Index
*/
/** @param string[] $columns */
protected function index(string $name, array $columns, bool $unique = false, bool $primary = false): Index
{
return new Index($name, $columns, $unique, $primary);
}

/**
* @return Column[]
*/
abstract protected function columns();
/** @return Column[] */
abstract protected function columns(): array;

/**
* @return Index[]
*/
abstract protected function indices();
/** @return Index[] */
abstract protected function indices(): array;
}
Loading
Loading