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

Can't install Analogue on Laravel 6 #291

Open
IbrahimFathy19 opened this issue Apr 13, 2020 · 16 comments
Open

Can't install Analogue on Laravel 6 #291

IbrahimFathy19 opened this issue Apr 13, 2020 · 16 comments

Comments

@IbrahimFathy19
Copy link

I can't install Analogue on fresh installation of Laravel 6
This is my composer.json

 "require": {
        "php": "^7.2",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "^6.0",
        "laravel/tinker": "^1.0"
    }, 

and this is the error produced when trying composer require analogue/orm:6.*

./composer.json has been updated

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install analogue/orm v6.0.1
    - Conclusion: don't install analogue/orm v6.0.0
    - Conclusion: remove laravel/framework v6.18.6
    - Installation request for analogue/orm 6.* -> satisfiable by analogue/orm[6.0.x-dev, v6.0.0, v6.0.1].
    - Conclusion: don't install laravel/framework v6.18.6
    - analogue/orm 6.0.x-dev requires illuminate/database 6.0.* -> satisfiable by laravel/framework[v6.0.0, v6.0.1, v6.0.2, v6.0.3, v6.0.4], illuminate/database[v6.0.0, v6.0.1, v6.0.2, v6.0.3, v6.0.4].
    - Can only install one of: laravel/framework[v6.0.0, v6.18.6].
    - Can only install one of: laravel/framework[v6.0.1, v6.18.6].
    - Can only install one of: laravel/framework[v6.0.2, v6.18.6].
    - Can only install one of: laravel/framework[v6.0.3, v6.18.6].
    - Can only install one of: laravel/framework[v6.0.4, v6.18.6].
    - don't install illuminate/database v6.0.0|don't install laravel/framework v6.18.6
    - don't install illuminate/database v6.0.1|don't install laravel/framework v6.18.6
    - don't install illuminate/database v6.0.2|don't install laravel/framework v6.18.6
    - don't install illuminate/database v6.0.3|don't install laravel/framework v6.18.6
    - don't install illuminate/database v6.0.4|don't install laravel/framework v6.18.6
    - Installation request for laravel/framework (locked at v6.18.6, required as ^6.0) -> satisfiable by laravel/framework[v6.18.6].


Installation failed, reverting ./composer.json to its original content. 
@adrorocker
Copy link
Member

adrorocker commented Apr 13, 2020

@IbrahimFathy19 This is due to the constraint on the laravel packages version that analogue require. Most likely the laravel version installed in your project is grater than 6.0.*. I will be happy if you can bump the version of those packages 1, 2 and run the tests, if they pass ok just create a PR and happly I would merge it.

Sorry if I'm not able to do it myself but right now I'm short in time. Also please use brench 6.0 as base.

@IbrahimFathy19
Copy link
Author

The tests produced:

PHPUnit 8.5.3 by Sebastian Bergmann and contributors.

.......E...................R......E.R......R..............R.R..  63 / 170 ( 37%)
......RRRR..................................................... 126 / 170 ( 74%)
..............R.............................                    170 / 170 (100%)

Time: 6.86 seconds, Memory: 44.00 MB

There were 2 errors:

1) AggregateTest::we_can_use_custom_id
ErrorException: Cannot use "parent" when current class scope has no parent

/var/www/html/analogue-orm/src/EntityMap.php:494
/var/www/html/analogue-orm/tests/src/Maps/UserMap.php:12
/var/www/html/analogue-orm/src/System/Manager.php:520
/var/www/html/analogue-orm/src/System/Manager.php:496
/var/www/html/analogue-orm/src/System/Manager.php:454
/var/www/html/analogue-orm/src/System/Manager.php:414
/var/www/html/analogue-orm/src/System/Manager.php:246
/var/www/html/analogue-orm/src/System/Manager.php:181
/var/www/html/analogue-orm/src/System/Manager.php:153
/var/www/html/analogue-orm/vendor/analogue/factory/src/FactoryBuilder.php:95
/var/www/html/analogue-orm/vendor/analogue/factory/src/FactoryBuilder.php:112
/var/www/html/analogue-orm/vendor/analogue/factory/src/FactoryBuilder.php:76
/var/www/html/analogue-orm/tests/AnalogueTestCase.php:186
/var/www/html/analogue-orm/tests/cases/AggregateTest.php:20

2) EntityTest::we_cant_see_hidden_attributes_when_converting_to_array_or_json
ErrorException: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead

/var/www/html/analogue-orm/tests/cases/EntityTest.php:32

--

There were 10 risky tests:

1) CollectionProxyTest::we_can_remove_from_a_collection_proxy_without_loading_it
This test did not perform any assertions

/var/www/html/analogue-orm/tests/cases/CollectionProxyTest.php:176

2) EntityTest::we_can_convert_an_entity_to_json
This test did not perform any assertions

/var/www/html/analogue-orm/tests/cases/EntityTest.php:44

3) EventTest::global_events_are_fired
This test did not perform any assertions

/var/www/html/analogue-orm/tests/cases/EventTest.php:12

4) ManagerTest::we_can_register_with_an_object_instance
This test did not perform any assertions

/var/www/html/analogue-orm/tests/cases/ManagerTest.php:92

5) ManagerTest::we_can_register_a_custom_plugin
This test did not perform any assertions

/var/www/html/analogue-orm/tests/cases/ManagerTest.php:109

6) MapperTest::we_can_apply_a_custom_scope
This test did not perform any assertions

/var/www/html/analogue-orm/tests/cases/MapperTest.php:96

7) MapperTest::we_can_query_without_a_global_scope_if_one_is_applied
This test did not perform any assertions

/var/www/html/analogue-orm/tests/cases/MapperTest.php:102

8) MapperTest::we_can_register_a_custom_event
This test did not perform any assertions

/var/www/html/analogue-orm/tests/cases/MapperTest.php:108

9) MapperTest::we_can_register_and_call_custom_command
This test did not perform any assertions

/var/www/html/analogue-orm/tests/cases/MapperTest.php:114

10) HasManyThroughTest::we_can_store_a_related_entity
This test did not perform any assertions

/var/www/html/analogue-orm/tests/cases/Relationships/HasManyThroughTest.php:6

ERRORS!
Tests: 170, Assertions: 453, Errors: 2, Risky: 10.

@IbrahimFathy19
Copy link
Author

And this is the composer file:

{
    "name": "analogue/orm",
    "description": "An intuitive Data Mapper ORM for PHP and Laravel",
    "keywords": [
        "orm",
        "datamapper",
        "laravel",
        "entity",
        "repository",
        "mapper"
    ],
    "homepage": "http://github.com/analogueorm/analogue",
    "license": "MIT",
    "authors": [
        {
            "name": "Rémi Collin",
            "email": "remi@code16.fr"
        },
        {
            "name": "Adro Rocker",
            "email": "me@adro.rocks",
            "homepage": "https://github.com/adrorocker"
        }
    ],
    "require": {
        "php": ">=7.2.0",
        "illuminate/database": "^6.0",
        "illuminate/events": "^6.0",
        "illuminate/pagination": "^6.0",
        "doctrine/instantiator": "^1.0.0",
        "ocramius/proxy-manager": "^2.0.0",
        "ocramius/generated-hydrator": "^2.0.0",
        "psr/simple-cache": "~1.0",
        "psr/container": "~1.0"
    },
    "require-dev": {
        "phpunit/phpunit": "~8.0",
        "laravel/laravel": "^6.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "symfony/css-selector": "2.8.*|3.0.*|4.0.*",
        "symfony/dom-crawler": "2.8.*|3.0.*|4.0.*",
        "analogue/factory": "1.2.*|1.3.*",
        "laravel/browser-kit-testing": "^1.0"
    },
    "suggest": {
        "analogue/laravel-auth": "Analogue's authentication driver for Laravel.",
        "analogue/factory": "Create simple dummy entities for your tests",
        "analogue/mongodb": "MongoDB driver for Analogue ORM"
    },
    "autoload": {
        "psr-4": {
            "Analogue\\ORM\\": "src/"
        },
        "files": [
            "src/helpers.php"
        ]
    },
    "autoload-dev": {
        "classmap": [
            "tests/AnalogueTestCase.php",
            "tests/DomainTestCase.php",
            "tests/ClassFinder.php"
        ],
        "psr-4": {
            "TestApp\\": "tests/src"
        },
        "files": [
            "tests/helpers.php"
        ]
    },
    "extra": {
        "laravel": {
            "providers": [
                "Analogue\\ORM\\AnalogueServiceProvider"
            ],
            "aliases": {
                "Analogue": "Analogue\\ORM\\AnalogueFacade"
            }
        }
    }
}

@adrorocker
Copy link
Member

I think is better if we restrict the version a little more so we can control possible braking changes in laravel packages.

Maybe you can do something like

...
        "illuminate/database": "6.0.* | 6.1.* | 6.2.*",
        "illuminate/events": "^6.0 | 6.1.* | 6.2.*",
        "illuminate/pagination": "^6.0 | 6.1.* | 6.2.*",
...

So on and so forth.

Do you think you can fix those issues on the tests and make travis test those different version?

@IbrahimFathy19
Copy link
Author

I can gladly solve the two errors, but to write the other 10 tests, well this would take some time.

@IbrahimFathy19
Copy link
Author

I will do it during these two weeks

@adrorocker
Copy link
Member

@IbrahimFathy19 If you can write tests for those 10 empty ones would be awesome, but if you would like we can merge the fix for those 2 errors and make a release for you to use on your project and make another release when those tests are complete.

TBH those empty tests were there since long ago, way before I became a contributor. @RemiCollin any suggestion you can provide on this?

@IbrahimFathy19
Copy link
Author

IbrahimFathy19 commented Apr 13, 2020

It would be much help if we could make a release with the correct versions! can we do that?
As I have an arguent task and It will save much time

@adrorocker
Copy link
Member

Ok, help me fix the 2 errors and I will make a release with the correct version needed. Can you provide the version of laravel you have installed?

@IbrahimFathy19
Copy link
Author

Laravel 6.1.18, Laravel 6.2

@IbrahimFathy19
Copy link
Author

IbrahimFathy19 commented Apr 14, 2020

Well the first error can be resolved By removing the check if the class EntityMap has a parent class or not

 public function getProperties(): array
    {
        return get_parent_class(__CLASS__) !== false
            ? array_unique(array_merge($this->properties, parent::getProperties()))
            : $this->properties;
    }

As I believe the error is produced based on parsing the file maybe!
So I might just return this->properties without the condition, as the EntityMap doesn't actually have a parent

 public function getProperties(): array
    {
        return $this->properties;
    }

And with this code all the tests pass

@IbrahimFathy19
Copy link
Author

The second one is resolved by using property_exists() instead of array_key_exists()

@adrorocker
Copy link
Member

@IbrahimFathy19 I published a new release. Please feel free to close this issue if this new release resolve your problem.

@IbrahimFathy19
Copy link
Author

well there's now
Laravel
v6.18.3
v6.18.0
v6.12.0
v6.8.0
v6.5.2
v6.4.0
v6.2.0
v6.0.2
v6.0.1
Your update will crash with the updated versions of Laravel 6

@IbrahimFathy19
Copy link
Author

We might run the tests for all of these versions and edit composer.json based on the results maybe!?

@adrorocker
Copy link
Member

I’ll work on this as soon as I have time to do it. As I mention before my free time is nearly null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants