mirror of
https://github.com/doctrine/orm.git
synced 2026-04-29 09:23:20 +02:00
"orm:schema-tool:update --force" from within a PHAR archive leads to "No Metadata Classes to process" #5147
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @s0me0ther on GitHub (Jun 9, 2016).
Originally assigned to: @s0me0ther on GitHub.
Stackoverflow Link
Github Example
PHP 5.6.3I'm on the way to build a complete php application in a PHAR archive.
Therefore i want to programmatically build a sqlite database and several other files, if they dont exists in the root folder, where the phar archive is executed.
If i programmatically want to execute
orm:schema-tool:update --force, it will perfect work, when triggered by console, or apache - if the script is NOT in a phar archive.As soon as i execute the generated PHAR archive, which contains exactly the same code, the
orm:schema-tool:update --forcewill outputNo Metadata Classes to processIf the file
/Test/public/index.phpis via apache handler or console triggered, and the sqlite database/database.sqlitedoes not exist, doctrine will create the database by the annotations of the Entity.If you trigger the generated phar, the same code is triggered, but the output then is:
How is it possible to let Doctrine generate the sqlite file by the annotations - by execute the PHAR archive?
@Ocramius commented on GitHub (Jun 9, 2016):
Related? https://github.com/box-project/box2/issues/85
Also: is the metadata driver pointing at the correct path?
@s0me0ther commented on GitHub (Jun 9, 2016):
I think not - if i look into the phar archive, all annotations are fully there, nothing is removed.
Without PHAR execution its a normal absolute path, and correct.
With the PHAR execution its a Path into the PHAR archive
phar://C:/xampp/htdocs/Project/generated/client.phar/src/Entity, but the path is correct.if i
scandirthe phar uri from inside the phar, i get a full list of the entitiy files.I can even open the EntityFiles and get there contents with
file_get_contents- all annotations there, no problem in path or file itself.@s0me0ther commented on GitHub (Jun 9, 2016):
I got an quickfix for this - but i have no clue if this is the right way, please have a short look:
https://github.com/sebka/test.lh/commit/b5c881431a624b51da226834810f236260a3c23f
I give the path in my application as following:
Which results in path
phar://C:/xampp/htdocs/Project/generated/client.phar/src/Entity.Then in the
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.phpthere is aRegexIterator(Line 211) which gathers all files of the path.As result there is a foreach of all gathered files @ Line 220.
The output of the Entity Filename is like:
phar://C:/xampp/htdocs/Project/generated/client.phar/src/Entity\Request.phpMore bottom then he fetches all declared classes over
get_declared_classes- fetches the reflection class of each declared class and$sourceFile = $rc->getFileName();gets the source filename by the reflection class, which results in following:phar://C:/xampp/htdocs/Project/generated/client.phar/src/Entity/Request.phpThe source file will be compared via
in_arraywith the source file from the regex iterator - both are NOT the same.If i correct this issue with
$sourceFile = str_replace('\\', '/', $sourceFile);the sqlite databse is generated and all works as expected.So, this is a Windows / Unix Directory-Seperator problem..