leafsphp / leaf

🍁 The easiest way to create clean, simple but powerful web apps and APIs quickly
https://leafphp.dev
MIT License
1.1k stars 68 forks source link

Default project generated by `leaf create` does not work due to missing leafs/cookie #169

Closed Pascal-So closed 1 year ago

Pascal-So commented 1 year ago

Describe the bug

I created a fresh leaf project, and then, without changing anything, served it with php -S and tried to access it with my browser. The following error is displayed in my browser:

Leaf cookie not found. Run leaf install cookie or composer require leafs/cookie.

To Reproduce Steps to reproduce the behavior:

  1. Create a new project by running leaf create asdf --v3 --basic
  2. Serve it on localhost:8080
  3. Navigate to localhost:8080 with Firefox or some other browser.

Expected behavior

I expect the leaf cli to add all the required dependencies to make the generated project work out of the box.

On the other hand I'm wondering why leafs/cookie is an optional module, since basically every usecase will require the module. Checking the code of response()->json() and other response methods, it seems like the code will always try to call the sendCookies method even though I don't tell the framework to set any cookies anywhere. If this method is always called, the cookies module might as well be part of the core "leafs/leaf" package.

Additional context

leaf --version shows v2.6.0

Note that the same problem exists with the instructions given in the README.md of the leaf repository for a composer installation without the leaf cli. composer require leafs/leaf will not install the cookie module, so the given example won't work out of the box. Same for the documentation on the website: https://leafphp.dev/docs/introduction/installation.html#composer

mychidarko commented 1 year ago

This issue has been fixed now, thanks