"require": {
"infusionsoft/php-sdk": "^1.2",
"laravel/lumen-framework": "5.1.*",
"vlucas/phpdotenv": "~1.0",
"barryvdh/laravel-debugbar": "^2.2",
"goaop/framework": "^2.0",
"php-http/httplug": "^1.1",
"infusionsoft/old-php-isdk": "*"
},
I'm trying to use the "infusionsoft/old-php-isdk" which is in the packagist composer repository but it's not specific to Laravel. I'm using an order controller and it's code that I picked up from another developer so he references the current (and working) "infusionsoft/php-sdk" as the following
"use infusionsoft\infusionsoft;"
What namespace do I call it if it has no namespace from the package?
Here's the original link to the composer package.
https://packagist.org/packages/infusionsoft/old-php-isdk
Am I missing something? Do I need to assign it a namespace? What and where would I put it?
Related
I want to use Bcrypt of Laminas-Crypt package in one of my files. After running
composer require laminas/laminas-crypt,
composer dump-autoload,
composer update
I declared a use statement in my controller:
use Laminas\Crypt\Password\Bcrypt;
The application loaded without any errors, but as far as I am concerned, all namespaces should be registered in config/modules.config.php for the autoloader to load the namespaces accordingly. After adding Laminas\Crypt namespace to the folder the application threw an exception:
Uncaught Laminas\ModuleManager\Exception\RuntimeException: Module (Laminas\Crypt) could not be initialized. in C:\xampp\htdocs\phpLessons\Shortly\vendor\laminas\laminas-modulemanager\src\ModuleManager.php:180
My question is:
Can the application function properly without the namespace of the used package being defined in the config/modules.config.php of root directory?
How can the exception be handled?
Edit:
Here is the relevant part of composer.json
"require": {
"php": ">=8.1.0",
"laminas/laminas-component-installer": "^3.0",
"laminas/laminas-development-mode": "^3.2",
"laminas/laminas-skeleton-installer": "^1.0",
"laminas/laminas-mvc": "^3.3.4",
"laminas/laminas-db": "^2.12.0",
"laminas/laminas-mvc-form": "^2.0.0",
"laminas/laminas-json": "^3.2",
"laminas/laminas-log": "^2.13.1",
"laminas/laminas-cli": "^1.1.1",
"laminas/laminas-mvc-i18n": "^1.2.0",
"laminas/laminas-mvc-plugins": "^1.1.0",
"laminas/laminas-mvc-middleware": "^2.0.0",
"laminas/laminas-session": "^2.10.0",
"laminas/laminas-di": "^3.2.2",
"laminas/laminas-view": "^2.25",
"laminas/laminas-form": "3.7",
"laminas/laminas-crypt": "^3.9",
"ext-pdo": "*",
"laminas/laminas-mail": "^2.20",
"doctrine/orm": "^2.14",
"doctrine/dbal": "^3.2",
"symfony/yaml": "^5.4",
"symfony/cache": "^5.4",
"doctrine/common": "^3.4",
"doctrine/doctrine-orm-module": "^5.3"
},
and modules.config.php from config/autoload:
return [
'Laminas\Cache',
'Laminas\Paginator',
'Laminas\Mail',
'Laminas\Mvc\Plugin\FilePrg',
'Laminas\Mvc\Plugin\FlashMessenger',
'Laminas\Mvc\Plugin\Identity',
'Laminas\Mvc\Plugin\Prg',
'Laminas\Session',
'Laminas\Mvc\Middleware',
'Laminas\Mvc\I18n',
'Laminas\Form',
'Laminas\I18n',
'Laminas\Log',
'Laminas\InputFilter',
'Laminas\Filter',
'Laminas\Hydrator',
'Laminas\Di',
'Laminas\Db',
'Laminas\Router',
'Laminas\Validator',
'Laminas\DeveloperTools',
'Laminas\Diactoros',
'DoctrineModule',
'DoctrineORMModule',
'Application',
'User',
'Pages',
];
I have installed the package from composer I am trying to include file from vendor folder into controller but it does not including.
Here is what I am trying
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use src\Coinpayments;
use src\keys;
class CoinController extends Controller
{
public function DoIt(){
$cps = new CoinPaymentsAPI();
}
}
And this is in composer.json
"require": {
"php": "^7.1.3",
"coinpaymentsnet/coinpayments-php": "^1.0",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0"
},
In the result I am getting following error which is
Class 'App\Http\Controllers\CoinPaymentsAPI' not found
After a composer install it's advised to run
composer dump-autoload
In the instructions from the package they tell you to include the following file:
require('/your_installation_path_to/src/CoinpaymentsAPI.php');
You aren't including it correctly, pretty sure your IDE is giving you errors.
It's probably, I found this information in the composer.json file included in the package:
use Coinpaymentsnet\CoinpaymentsAPI
I upgraded symfony 3.3 to 3.4 and now having problem with datafixture bundle , trying to seed data for testing but got this error :
Attempted to call an undefined method named "addClass" of class
"Doctrine\ORM\Internal\CommitOrderCalculator"
this is part of my ccomposer.json file :
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0",
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
}
any help will be appreciated
You have to upgrade the data-fixtures manually in your composer.json file. Try to upgrade it to version 1.3 like this:
"doctrine/data-fixtures": "^1.3"
I am new to Laravel, and I have started working on Laravel 5.x( the current version on the question date). My app uses bunch of libraries, including Amazon MWS library, a parser and many more, see this image for an idea
these seems to be a lot of folder, and including Laravel Framework folder...
many of these built in options would never by used by me directly and intentionally..Also, say from a library, I would use only one method (tojson method from a lib for example)
Already admitted, I am new to Laravel, and from my native understanding, only parts of libraries are included when called..
So, my basic question is,
When and HOW do you know you are including too much ?
How you people manage this??
thanks...and sorry if my question seems offensive to anyone, I believe its directly relating to programming and will help many others like me too..
There's no problem with including many libraries.
Requiring and installing libraries doesn't create overhead in itself, as that code is executed only when you use it. Also most of the libraries in the vendor directory are Laravel dependencies.
If you look at the framework's composer.json file and you'll see that Laravel already has a lot of dependencies as it uses a lot of Symfony components for the core, Monolog for logging, SwiftMailer for sending emails, and the list goes on:
"require": {
"php": ">=5.5.9",
"ext-mbstring": "*",
"ext-openssl": "*",
"classpreloader/classpreloader": "~3.0",
"doctrine/inflector": "~1.0",
"jeremeamia/superclosure": "~2.2",
"league/flysystem": "~1.0",
"monolog/monolog": "~1.11",
"mtdowling/cron-expression": "~1.0",
"nesbot/carbon": "~1.20",
"paragonie/random_compat": "~1.4",
"psy/psysh": "0.7.*",
"swiftmailer/swiftmailer": "~5.1",
"symfony/console": "2.8.*|3.0.*",
"symfony/debug": "2.8.*|3.0.*",
"symfony/finder": "2.8.*|3.0.*",
"symfony/http-foundation": "2.8.*|3.0.*",
"symfony/http-kernel": "2.8.*|3.0.*",
"symfony/polyfill-php56": "~1.0",
"symfony/process": "2.8.*|3.0.*",
"symfony/routing": "2.8.*|3.0.*",
"symfony/translation": "2.8.*|3.0.*",
"symfony/var-dumper": "2.8.*|3.0.*",
"vlucas/phpdotenv": "~2.2"
},
Just install whatever you need, there's no limit to how many libraries you use as long as your code is written properly.
I'm having some trouble. I'm using Silex, and I'm trying to load the Paypal SDK into it. I think my issue is related to my understanding of Silex, which is why I'm posting it here.
My Setup
Paypal's developer website says to add a few lines to the composer file (PHP tab). So, I've done that. My new composer file looks like so (the last four entries were those suggested by Paypal):
{
"require": {
"silex/silex": "1.0.*#dev",
"symfony/browser-kit": "2.1.*",
"symfony/console": "2.1.*",
"symfony/css-selector": "2.1.*",
"symfony/dom-crawler": "2.1.*",
"symfony/filesystem": "2.1.*",
"symfony/finder": "2.1.*",
"symfony/form": "2.1.*",
"symfony/locale": "2.1.*",
"symfony/process": "2.1.*",
"symfony/security": "2.1.*",
"symfony/serializer": "2.1.*",
"symfony/translation": "2.1.*",
"symfony/validator": "2.1.*",
"symfony/monolog-bridge": "2.1.*",
"symfony/twig-bridge": "2.1.*",
"monolog/monolog": ">=1.0.0,<1.2-dev",
"twig/twig": ">=1.2.0,<2.0-dev",
"doctrine/dbal": ">=2.2.0,<2.4.0-dev",
"swiftmailer/swiftmailer": "4.1.*",
"php": ">=5.3.0",
"ext-curl": "*",
"ext-json": "*",
"paypal/rest-api-sdk-php" : "0.7.*"
}
}
Then, I ran composer update, and it updated everything. I checked in the vendor folder, and a paypal folder had been created and seemed to be good to go.
The Problem
Unfortunately, even though I've done the above steps, it still isn't working. I'm following the beginners steps outlined on Paypal's website, it seems that one of the Paypal classes can't be located.
The line that causes the error is taken directly from the "beginners steps" page linked to above. For quick reference, I'll provide it below as well:
$cred = new OAuthTokenCredential("AQkquBDf1zctJOWGKWUEtKXm6qVhueUEMvXO_-MCI4DQQ4-LWvkDLIN2fGsd","EL1tVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX", $sdkConfig);
Unfortunately that line causes an error that says:
Fatal error: Class 'OAuthTokenCredential' not found in ...
Summed up...
The problem seems to be that Silex isn't loading--or making available--the class OAuthTokenCredential. What do I do?
Thanks Laurynas MaliĊĦauskas and user2930475 for this answer (in the comments of my post).
Looks like I had neglected to put a line such as:
use PayPal\Auth;
in my app.php file.
Once added, I also needed to change my new class line to this:
$cred = new PayPal\Auth\OAuthTokenCredential("AQkquBDf1zctJOWGKWUEtKXm6qVhueUEMvXO_-MCI4DQQ4-LWvkDLIN2fGsd","EL1tVxAjhT7cJimnz5-Nsx9k2reTKSVfErNQF-CmrwJgxRtylkGTKlU4RvrX", $sdkConfig);
Note that I have all of my controllers actually in the app.php file.
Actually, you don't need to add anything to app.php at all. Just do this:
use PayPal\Auth\OAuthTokenCredential.php;
class YourController{
public function myAction(){
// ...
$cred = new OAuthTokenCredential("AQkquB...","EL1tVx...", $sdkConfig);
// ...
}
}
You should never need to modify app.php just to use a class.