• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trying to use Composer

#1
I am trying to load up the AWS PHP sdk. The install instructs say to use composer, which I did. It then states:

Require the Composer autoloader in your scripts.


Code:
<?php
  require '/path/to/vendor/autoload.php';
?>

what is /path/to/vendor/ mean? what vendor? Are they talking about the vendor directory in my CI project? I see an autoload.php in my vendor directory in my CI project. But how do I path to this? from the root of the project which would be /xxx/vendor/autoload.php.  I don't know what xxx would be? My prject is call sub_crud so would it be /sub_crud/vendor/autoload.php ?

I copied /aws/s3 into third_party/

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 require 'vendor/autoload.php';

use third_party\Aws\S3\S3Client;


But looking in the S3 directory, I see all the files are .java. Does that mean I have the wrong version of the sdk? Should they be .php?

But when I start up the AWS\S3\S3Client can't be found. 
proof that an old dog can learn new tricks
Reply

#2
I have given up trying to use Composer. I have tried it before and it has NEVER worked for me. I am going to close this topic.
proof that an old dog can learn new tricks
Reply

#3
Did you change the configuration setting?
https://codeigniter.com/user_guide/gener...t=composer
Reply

#4
Thanks. I did that now. I am still getting error below. I removed the third_party\vendor\aws\s3 directory but with little effect. I also set
$config['composer_autoload'] = TRUE; in config.php


( ! ) Fatal error: Class 'S3Client' not found in C:\xampp\htdocs\sub_crud\application\controllers\Configure.php on line 1145
Call Stack
# Time Memory Function Location
1 0.2160 152800 {main}( ) ...\index.php:0
2 0.2500 199312 require_once( 'C:\xampp\htdocs\sub_crud\system\core\CodeIgniter.php' ) ...\index.php:316
3 0.2820 1175432 Configure->__construct( ) ...\CodeIgniter.php:518
4 0.3280 3588080 Configure->_init( ) ...\Configure.php:21
5 0.3290 3589096 Configure->test( ) ...\Configure.php:38
A PHP Error was encountered
Severity: Error

Message: Class 'S3Client' not found

Filename: controllers/Configure.php

Line Number: 1145

Here is the code I am trying to run:
Code:
 public  function test(){
       //Create a S3Client
       $s3Client = new S3Client([
           'profile' => 'default',
           'region' => 'us-east-1',
           'version' => 'latest'
       ]);

//Listing all S3 Bucket
       $buckets = $s3Client->listBuckets();
       foreach ($buckets['Buckets'] as $bucket){
           echo $bucket['Name']."\n";
       }
   }
The instructs for autoload that you sent me says to :
The following items can be loaded automatically:
  • Classes found in the libraries/ directory

  • Helper files found in the helpers/ directory

  • Custom config files found in the config/ directory

  • Language files found in the system/language/ directory

  • Models found in the models/ folder
But I don't recall being asked by Composer where to put the Classes!!! I have no idea where they went.
proof that an old dog can learn new tricks
Reply

#5
Check your vendor directory, that's where it usually places them.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#6
I tried putting this at the top of my controller:


require 'Application/third_party/aws/aws-autoloader.php';


But I am still getting:

A PHP Error was encountered

Severity: Error

Message: Class 'S3Client' not found

Filename: controllers/Configure.php

Line Number: 1157


So I reinstalled with Composer. Now I put this line at the top of my controller:
require 'vendor/autoload.php';

But I still get Message: Class 'S3Client' not found!


proof that an old dog can learn new tricks
Reply

#7
I refuse to give up. I am stepping through the loadClass function in ClassLoader.php. This line is reached:

if ($file = $this->findFile($class)) //$class = "Aws\s3\S3Client"

this file is not being found. I do see a file called S3Client.php in the third_party/aws/AWS/S3/S3Client.php

Two questions 1) does the code know to look in /third_party? 2) do you think that the two aws's is screwing it up 3) what's up with the missing .php?
proof that an old dog can learn new tricks
Reply

#8
looks like you have two aws directories.

$class is only showing one aws directory.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#9
That's not it. I tried moving everything from Aws/aws to just aws.

$file = $this->findFile($class)) << this is failing when $class is "Aws\S3\S3Client"

Tracing through i see that the s3Client is not being found in the $this->classmap. The reason is that it is looking for things in C:\xampp\htdocs\sub_crud\vendor\composer/../

But I am not using composer! I have set $config['composer_autoload'] = FALSE;

What do I do? I am willing to try to install with Composer one more time. But there seems no way to uninstall Composer. When I install from Composer, do I need to be in the sub_crud/Vendor/ directory first?
proof that an old dog can learn new tricks
Reply

#10
I got it working (or at least not crashing). All I did was reinstall Composer.
proof that an old dog can learn new tricks
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.