Hybridauth on Codeigniter Could not load the Hybrid_Auth class - codeigniter

I have installed hybridauth via composer and then followed the steps given here, but always get the following error:
Could not load the Hybrid_Auth class
Any solution to this?

Use:
$this->load->library('hybridauth');
in your controller to load the library.

application/composer.json
{
"require" : {
"hybridauth/hybridauth" : "~3.0"
},
"config": {
"platform": {
"php": "X.X.XX" //SET your php version
}
}
}
and change config file application/config/config.php
$config['composer_autoload'] = TRUE;

Related

use Laravel Excel inside laravel package development

I'm creating my own Laravel package for the first time. I create a new project and require orchestra/testbench in the project. Things look okay and I'm able to run tests inside the package but I couldn't use Laravel Excel inside my package.
in composer.json I added
"extra": {
"laravel": {
"providers": [
"Maatwebsite\\Excel\\ExcelServiceProvider"
],
"aliases": {
"Excel": "Maatwebsite\\Excel\\Facades\\Excel",
}
}
},
"require-dev": {
"orchestra/testbench": "6.0",
"phpunit/phpunit": "^9.5",
"maatwebsite/excel": "^3.1"
}
And also ran composer dump-autoload, when I want to use Laravel Excel inside my package I tried
use Maatwebsite\Excel\Facades\Excel;
class TaxCalculation {
public function incomeTax(): float
{
$table = Excel::import(new TaxImport(), 'file.xls');
}
But got an error
Illuminate\Contracts\Container\BindingResolutionException: Target class [excel] does not exist.
D:\code\packages\thai_tax\vendor\laravel\framework\src\Illuminate\Container\Container.php:832
D:\code\packages\thai_tax\vendor\laravel\framework\src\Illuminate\Container\Container.php:712
D:\code\packages\thai_tax\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:796
D:\code\packages\thai_tax\vendor\laravel\framework\src\Illuminate\Container\Container.php:651
D:\code\packages\thai_tax\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:781
D:\code\packages\thai_tax\vendor\laravel\framework\src\Illuminate\Container\Container.php:1354
D:\code\packages\thai_tax\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php:198
D:\code\packages\thai_tax\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php:166
D:\code\packages\thai_tax\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php:255
D:\code\packages\thai_tax\src\Services\TaxCalculation.php:45
D:\code\packages\thai_tax\tests\Unit\CreateFacadeTest.php:26
Caused by
ReflectionException: Class excel does not exist
Excel does not seem to load. Is there any more steps I need to do to use it?

Composer autoload in own package / class not found

I've tried now some different approaches and read articles here and elsewhere but i can't figure out what i'm doing wrong.
I'm developing a package and I want it to be installed via symlink in a different project to develop both parts simultaneously without the need of updating the dependencies over and over again.
The thing I cant get to work is the autoloading.
Here is my setup:
Project composer.json
{
"repositories": [
{
"type": "path",
"url": "../../FormTableComponent",
"options": {
"symlink": true
}
}
],
"require": {
[...]
"bluechord/formtablecomponent": "#dev"
}
}
FormtableComponent Folder Structure
FormTableComponent/
src/
| Container.php
composer.json
FormtableComponent composer.json
{
"name": "bluechord/formtablecomponent",
"description": "...",
"autoload": {
"psr-4": {
"BlueChord\\FormTableComponent\\": "src/"
}
},
"require" : {
[...]
}
}
FormtableComponent Container.php
<?php
/**
* FormTable Container. The Container Class that registers all Parts of the
* Component.
*/
namespace BlueChord\FormTableComponent;
class Container {
function __construct() {
}
}
When I try to use the class and instantiate it I get
Uncaught Error: Class 'BlueChord\FormTableComponent\Container' not found
Thanks for your help!
ADDITIONAL INFO:
A simple Test.php which reproduces the error inside the project
<?php
require_once 'bin/vendor/autoload.php';
echo "BCOSP Test";
use DebugBar\StandardDebugBar;
use BlueChord\FormTableComponent\Container;
$debugbar = new StandardDebugBar(); --> WORKS
echo StandardDebugBar::class ."\n";
$container = new Container(); --> ERROR
echo Container::class . "\n";
Composer
The vendor/composer/autoload_psr4.php does NOT contain any array key for my package.
If I run composer dump-autoload inside my main project nothing changes.
If I run composer dump-autoload inside my package it creates the correct autoload_psr4.php

What is wrong in my composer psr-4 autoload?

I'm creating a web app with Slim and Twig. The libraries I use work perfectly, I can call them easily with no problem. However my own classes are not found by composer.json autoload psr-4 (psr-0 doesn't find them either)
Here is my file system:
project
|composer.json
|src
|public
| |index.php
|classes
| |Application.php
| |middlewares
| |SecurityMiddleware.php
|templates
|TemplateController.php
|main
|MainController.php
Here is my composer.json:
{
"authors": [
{
"name": "Jean-Marc ZIMMER",
"email": "#################gmail.com",
"role": "Developer"
}
],
"require": {
"slim/slim": "^3.11",
"slim/extras": "*",
"twig/twig": "^2.5",
"slim/twig-view": "^2.4",
"slim/views": "^0.1.3"
},
"autoload": {
"psr-4": {
"src\\": "src",
"middlewares\\": "src/classes/middlewares",
"classes\\": "src/classes",
"templates\\": "src/templates"
}
}
}
Then src/classes/Application.php:
<?php
namespace classes;
class Application extends \Slim\App {
public function __construct($container = array()) {
parent::__construct($container);
}
}
And finally my index.php file:
<?php
require '../../vendor/autoload.php';
$app = new \classes\Application([
"settings" => [
"displayErrorDetails" => true
]
]);
$app->run();
When I run composer dump-autoload, the command outputs:
Generated autoload files containing 0 classes
then exits with status code 0. It should find 4 classes, right ?
And running the app shows the error:
Fatal error: Uncaught Error: Class 'classes\Application' not found in /opt/lampp/htdocs/project/src/public/index.php:5
I'm sure I'm missing something, indicating a namespace or something. Can anyone help me ?
Edits:
I tried using the --optimize or the --classmap-authoritative option for dump-autoload. Changed nothing.
Adding a '/' to the folder names in composer.json doesn't change anything.
I got a solution from another source. I don't personally like it, but it works.
The file system wasn't changed.
composer.json autoload:
"autoload": {
"psr-4": {
"App\\": "src/"
}
}
src/public/index.php:
<?php
require '../../vendor/autoload.php';
$app = new \App\classes\Application([
"settings" => [
"displayErrorDetails" => true
]
]);
$app->run();
src/classes/Application.php:
<?php
namespace App\classes;
class Application extends \Slim\App {
public function __construct($container = array()) {
parent::__construct($container);
}
}
I'm going to work from this functional base and see if I can get the result I want. If I do, I'll edit this answer.
Ensure your composer.json references your deployment paths. For example:
Dockerfile
FROM php:7.2-apache
COPY src /var/www/html
COPY vendor /var/www/vendor
composer.json
{
"autoload": {
"psr-4": {
"Acme\\": "html/classes/"
}
}
}
i.e. html/classes/ not src/classes/

Why does composer autoload not work on macOS Docker containers?

The file structure is as follows:
index.php
composer.json
composer.lock
-lib
--books
---SearchClient.php (contains class books\SearchClient
The following docker-compose.yml + PHP works on Windows:
{
"name" : "keithdavis/books",
"description" : "",
"version" : "0.1",
"minimum-stability": "beta",
"require" : {
"ext-curl" : "*",
"ext-json" : "*",
"guzzlehttp/guzzle": "^6.3"
},
"autoload" : {
"psr-4": {
"books\\": "lib"
}
}
}
<?php
use books\SearchClient;
require_once __DIR__."/vendor/autoload.php";
$oSearchClient = new SearchClient();
However, on macOS (Mojave):
( ! ) Fatal error: Uncaught Error: Class 'books\SearchClient' not found in /var/www/html/search.php on line 6
( ! ) Error: Class 'books\SearchClient' not found in /var/www/html/search.php on line 6
Call Stack
# Time Memory Function Location
1 0.0032 416944 {main}( ) .../search.php:0
In debugging, it appears the path "lib" is the problem, but I've tried "/lib" and that does not work either. I think maybe I have Composer installed incorrectly. I'm an experienced PHP developer on Windows, but relatively new to Mac and so I'm not 100% about the best way to install Composer on Mac. I followed these instructions globally:
https://getcomposer.org/doc/00-intro.md#globally
Looking at your file structure the namespace for you search client class would need to be
namespace books\books;
This is because you are setting the namespace book on the lib folder. Instead of using book twice in the namespace you could point the autoloader directly to the book folder by adding
{
"name" : "keithdavis/books",
"description" : "",
"version" : "0.1",
"minimum-stability": "beta",
"require" : {
"ext-curl" : "*",
"ext-json" : "*",
"guzzlehttp/guzzle": "^6.3"
},
"autoload" : {
"psr-4": {
"books\\": "lib/books"
}
}
}
Make sure you run composer dumpautoload when changing the autoload so that you rebuild the namespaces.
Hope this helps.

cakephp 3.0 recaptcha installation

I try to use recaptcha with cakePHP 3.0, but I experience some errors probably dues to a wrong installation.
I work on Windows with composer.
I've add the following lines to composer.json file :
"require": {
(...)
"google/recaptcha": "~1.1"
},
"autoload": {
"psr-4": {
(...)
"ReCaptcha\\": "/vendor/google/recaptcha/src/ReCaptcha"
}
},
Then I execute composer cmd to install the plugin:
composer update
composer install
composer dumpautoload
Finally, I test the plugin in a view :
<?php
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
$resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp);
if ($resp->isSuccess()) {
// verified!
} else {
$errors = $resp->getErrorCodes();
}
?>
The result is an error throwed by cake :
"No secret provided (...) Could this be caused by using Auto-Tables? ..."
Did I correctly installed it ?
Did I miss or misunderstand something ?

Resources