antonioribeiro / countries

Laravel countries and currencies
BSD 3-Clause "New" or "Revised" License
1.82k stars 280 forks source link

Getting an error when try to instantiate new Countries(); #125

Open biopowder opened 5 years ago

biopowder commented 5 years ago

Laravel: 6 PHP: PHP Version 7.3.8

Code:

$countries = new Countries();
        $all = $countries->all();
        dd($all);

Error:

 Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to undefined function PragmaRX\Coollection\Package\camel_case()

Stacktrace:

 …/vendor/pragmarx/coollection/src/package/Coollection.php353
53
PragmaRX\Coollection\Package\Coollection camelCase
…/vendor/pragmarx/coollection/src/package/Coollection.php292
52
PragmaRX\Coollection\Package\Coollection getArrayKey
…/vendor/pragmarx/coollection/src/package/Coollection.php364
51
PragmaRX\Coollection\Package\Coollection getByPropertyName
…/vendor/pragmarx/coollection/src/package/Coollection.php182
50
PragmaRX\Coollection\Package\Coollection __get
…/vendor/pragmarx/countries/src/package/Services/Config.php74
49
PragmaRX\Countries\Package\Services\Config __get
…/vendor/pragmarx/countries/src/package/Services/Cache/Managers/Nette.php66
48
PragmaRX\Countries\Package\Services\Cache\Managers\Nette getCacheDir
…/vendor/pragmarx/countries/src/package/Services/Cache/Managers/Nette.php86
47
PragmaRX\Countries\Package\Services\Cache\Managers\Nette getStorage
…/vendor/pragmarx/countries/src/package/Services/Cache/Managers/Nette.php44
46
PragmaRX\Countries\Package\Services\Cache\Managers\Nette __construct
…/vendor/pragmarx/countries/src/package/Services/Cache/Service.php68
45
PragmaRX\Countries\Package\Services\Cache\Service instantiateManager
…/vendor/pragmarx/countries/src/package/Services/Cache/Service.php43
44
PragmaRX\Countries\Package\Services\Cache\Service __construct
…/vendor/pragmarx/countries/src/package/Services/Countries.php69
43
PragmaRX\Countries\Package\Services\Countries __construct
…/vendor/pragmarx/countries/src/package/Countries.php36
42
PragmaRX\Countries\Package\Countries __construct 
dellow commented 5 years ago

Yup, I'm getting the same thing. Pretty much any query:

$c = \PragmaRX\Countries\Package\Countries::where('name.common', 'United Kingdom')->first();
dd($c);
DavidSporer commented 4 years ago

Same thing for me. I guess this must be caused by some dependency since the package itself hasn't changed, right?

DavidSporer commented 4 years ago

No it has changed: https://github.com/antonioribeiro/countries/commit/d6ccd36e4e983d0b7142a151d7ad5c544070943b And it also sounds like this is most likely the problem.

DavidSporer commented 4 years ago

Problem is that in ia-str the function camel_case has been removed (this commit: https://github.com/antonioribeiro/ia-str/commit/cc6c232da986f7e808b7dee48bf0e3b75bc349eb#diff-07f5c0ef2af42d2ee5412a1d79c49eac). Looks like this is related to the upgrade to Laravel 6 but the dependency from 0.6.0 (pragmarx/countries) should be 5.8.x to make this work but it actually is not explicitly specifying the dependency. I didn't dig deep enough to find out what requires ia-str but what works as a workaround for now is requiring ia-str in a lower version. In my case I set it to the version I've used before: "pragmarx/ia-str": "5.8.7"

I'm using pragmarx/countries in version 0.6.0 and did run a composer upgrade today. Afterwards things broke. During the composer upgrade pragmarx/ia-arr, pragmarx/ia-collection and pragmarx/ia-str have been upgraded to version 6.0.3 each.

karser commented 4 years ago

Most likely you have "pragmarx/countries": "^0.5" in composer.json. Change it to "pragmarx/countries": "^0.7" and update the deps.

DavidSporer commented 4 years ago

@karser sure but shouldn't "pragmarx/countries": "^0.5" require the correct versions of the dependencies? Right now if you run composer upgrade everything breaks with 0.5.x but I think it should require the correct versions of the ia-str lib.

karser commented 4 years ago

It should I suppose.

antonioribeiro commented 4 years ago

Sorry for this mess. Would you please check it now?

biopowder commented 4 years ago

Can't test due to another issue: mkdir(): Permission denied

ErrorException …/vendor/pragmarx/countries/src/package/Services/Cache/Managers/Nette.php66 49 mkdir …/vendor/pragmarx/countries/src/package/Services/Cache/Managers/Nette.php66 48 PragmaRX\Countries\Package\Services\Cache\Managers\Nette getCacheDir …/vendor/pragmarx/countries/src/package/Services/Cache/Managers/Nette.php83 47 PragmaRX\Countries\Package\Services\Cache\Managers\Nette getStorage …/vendor/pragmarx/countries/src/package/Services/Cache/Managers/Nette.php42 46 PragmaRX\Countries\Package\Services\Cache\Managers\Nette construct …/vendor/pragmarx/countries/src/package/Services/Cache/Service.php68 45 PragmaRX\Countries\Package\Services\Cache\Service instantiateManager …/vendor/pragmarx/countries/src/package/Services/Cache/Service.php43 44 PragmaRX\Countries\Package\Services\Cache\Service construct …/vendor/pragmarx/countries/src/package/Services/Countries.php70 43 PragmaRX\Countries\Package\Services\Countries construct …/vendor/pragmarx/countries/src/package/Countries.php36 42 PragmaRX\Countries\Package\Countries construct

DavidSporer commented 4 years ago

Sorry for this mess. Would you please check it now?

It seems to be working. I think the error that biopowder mentioned is unrelated to this issue.

vinkev commented 4 years ago

for laravel 6, execute this

composer require laravel/helpers