directus / v8-archive

Directus Database API — Wraps Custom SQL Databases with a REST/GraphQL API
https://docs.directus.io/api/reference.html
507 stars 204 forks source link

Installing S3 SDK breaks api #620

Closed Kinzi closed 5 years ago

Kinzi commented 5 years ago

Bug Report

After installing the S3 SDK via composer as explained here the app breaks. I get "Couldn't reach API" on the login screen.

PHP Error log:

PHP Fatal error:  Uncaught Error: Call to undefined function Directus\get_api_project_from_request() in /Users/seb/Code/directus7/src/web.php:16
Stack trace:
#0 /Users/seb/Code/directus7/public/index.php(3): require()
#1 {main}
  thrown in /Users/seb/Code/directus7/src/web.php on line 16

I don't get any other error message in directus logs. I'm on an MAMP environment.

Steps to Reproduce

  1. git clone directus suite // make install routine
  2. change config/api.php to use s3
  3. composer require aws/aws-sdk-php
  4. See error

Expected Behavior

Login and storage adapter working

Actual Behavior

unable to login

Other Context & Screenshots

Technical Details

wellingguzman commented 5 years ago

After debugging this, which was also reported here #606, the problem is that the build version in directus/directus doesn't include the composer.json file and when something is installed using composer the autoload is rewritten, removing all directus composer prs4 autoloading, removing all directus libraries from composer autoload.

I believe the proper way to fix this is to include the composer.json into the directus build repository.

ping @rijkvanzanten

subicura commented 5 years ago

Is there any other way to fix it? I want to use s3 for upload image.

jaredtbates commented 5 years ago

@subicura I worked around this issue by grabbing https://raw.githubusercontent.com/directus/api/master/composer.json and putting it in the root directory of the directus/directus repo, then running the command. I also found that you need to install flysystem, like with Directus 6, although that may be unrelated to this issue.

wellingguzman commented 5 years ago

@subicura, what @computerwizjared suggest is the way to go.

  1. Copy composer.json to your root directory.
  2. Run require aws/aws-sdk-php
  3. Run composer install

Everything should run normally.

benhaynes commented 5 years ago

Is that in the docs? @WellingGuzman

mrdotsign commented 5 years ago

I had to run the command composer require league/flysystem-aws-s3-v3 as well

subicura commented 5 years ago

It works! Thanks a lot!

wellingguzman commented 5 years ago

Is that in the docs? @WellingGuzman

no, this should be fixed in directus/directus, it's missing the composer.json. When that's done, it doesn't need those steps.

I had to run the command composer require league/flysystem-aws-s3-v3 as well

Thanks for pointing it out, it needs the league/flysystem-aws-s3-v3 package instead of aws/aws-sdk-php.

wellingguzman commented 5 years ago

Closed this ticket in favor of https://github.com/directus/directus/issues/2273

adamjgrant commented 5 years ago

@wellingguzman Should #2 be composer require aws/aws-sdk-php?

rijkvanzanten commented 5 years ago

@adamjgrant This issue is pretty old, and Welling has moved on from the project long since. If you're having any issues now, I recommend opening a new issue

MIShuvro commented 4 years ago

how do i install a directus for windows? Please help