I tried to take over an old project, the updates broke everything so I tried to make a clean installation from scratch and integrate my old code in it.
But there is something that doesn’t work, I have this error all the time:
I have to know that during the installation I had a conflict between PHP-DI and psr/container that I had to downgrade with -W flag.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires php-di/php-di ^6.4 -> satisfiable by php-di/php-di[6.4.0].
- php-di/php-di 6.4.0 requires psr/container ^1.0 -> found psr/container[1.0.0, 1.1.0, 1.1.1, 1.1.2] but the package is fixed to 2.0.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
In this case the real “issue” refers to PHP-DI as dependency. The error message is not related to the Slim router or basePath etc. as the title implies.
I have downloaded your example project, and it works with this command. Just an idea. Maybe try to delete the vendor/ directory and the composer.lock file and run composer update again.
Unfortunately it doesn’t change anything.
Is it possible that the problem comes from the fact that I’m using php 8.1 ? because I saw that PHP-DI 7 seems to bring php 8 support
Edit :
There is only one route that works: home ( localhost:8000/).
But all the others don’t work.
You can try for example localhost:8000/adduser which is the only unprotected one.
I guess not, because I use PHP 8.1 on my local dev machine, and it works with your example repository.
PS: According to the routing issue.
localhost:8000/adduser
This will not work, because there is no route like this in your project.
But there is a route like: localhost:8000/api/v1/addNewUser
Have you tried this url?
Damn, I’m really stupid. I don’t work on it since 2 years.
Indeed with the right road it works better!
I made some fixes but I still have a problem with the tokens.
Message: Call to undefined method Lcobucci\JWT\Builder::issuedBy()
File: /home/baudouin/Documents/DEV/pvappcore-test/src/Auth/JwtAuth.php
Line: 88
–
Hum I’m really do that ? . For me this is RESTfull but maybe I’m not doing it right. But i have followed you tutorial. So I probably miss something
It looks like your JwtAuth class is referring to an older version of the lcobucci/jwt package. Do you have the latest version of the eBook? You can also read the latest article online. Please send me a private message and I can check your email address.
For me this is RESTfull but maybe I’m not doing it right. But i have followed you tutorial. So I probably miss something
I never said that Can you show me where I recommend to build RPC-ish URI path?
The truth is, I don’t know what an RPC-ish URI path is.
I followed the old tutorial in 2019 when it was longer and before you created the eBook. So, since we can’t access the full version anymore, I can’t check. But as I say, this is probably me making a mistake.
–
Witch one ?
–
Yes, I am trying to reproduce the same thing I got with version 3. Actually the real repository is the one I’m trying to fix: https://github.com/LaBaude32/PvApp_Core
–
No I haven’t bought it yet, but I think I will soon but until now I was a student so I had little money.
Ok, no problem. Let me explain what I mean with “RPC-ish”. RPC means “Remote Procedure Call”, where you have method names in an API like “addNewUser” or “getUser” etc… When you use a URI path like /addNewUser or /getUser then this is looking very “RPC-ish” to me.
In practice, this style is not the way how to name RESTful API endpoints. Instead you would combine the HTTP method and the URI path to represent the resource you are trying to fetch, change or delete.
So instead of POST /addNewUser you would use POST /users,
and instead of GET getUser you would use GET /users.
Witch one ?
This article is only available if you buy the eBook.
I got with version 3
Yeah, this might be the point. The tutorial uses lcobucci/jwt v4.
This upgrading guide exlains how to upgrade lcobucci/jwt from version 3 to version 4. I hope it helps.