cakephp / cakephp/phinx

Migration classes do not comply with PSR-4 autoloading standard

Open
#1,784 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature major
Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

Hello,

After trying to run composer update (v 1.10.1), it started to complain about every single migration class not complying with PSR-4 autoloading standard and telling me it won't be autoloaded once we switch to composer v2.0.

All our migration classes reside in root/database/src/Migration and fall under namespace Pi\Database\Migration. As far as I can see, problem here is that each migration php file must be prefixed with timestamp and this timestamp is not used in class name and this is why it complains about PSR-4 standard.

I think one solution is would be to add timestamps to class names, are there any other ways to workaround this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the migration classes under database/src/Migration and the project's PSR-4 autoload configuration. Reproduce the warnings with composer update, then determine a compatible approach for the timestamped migration filenames. Done means migrations load without PSR-4 warnings under Composer 2 while remaining usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.