Uncaught Error: Class 'Symfony\CS\Config\Config' not found - php

I've been struggling with this all day. I got brought in to a new app and they require php-cs-fixer to be ran on all files. The project has a .php_cs file in it, but I couldn't get it work in sublime text 3 nor could I get vscode to do it.
The command runs but I get the error:
PHP Fatal error: Uncaught Error: Class 'Symfony\CS\Config\Config' not found in C:\dev\code\.php_cs:63
Stack trace:
#0 C:\Users\Alex\AppData\Roaming\Composer\vendor\friendsofphp\php-cs-fixer\src\Console\ConfigurationResolver.php(933): include()
#1 C:\Users\Alex\AppData\Roaming\Composer\vendor\friendsofphp\php-cs-fixer\src\Console\ConfigurationResolver.php(228): PhpCsFixer\Console\ConfigurationResolver::separatedContextLessInclude('c:\\dev\\code\\Tao...')
#2 C:\Users\Alex\AppData\Roaming\Composer\vendor\friendsofphp\php-cs-fixer\src\Console\ConfigurationResolver.php(625): PhpCsFixer\Console\ConfigurationResolver->getConfig()
#3 C:\Users\Alex\AppData\Roaming\Composer\vendor\friendsofphp\php-cs-fixer\src\Console\ConfigurationResolver.php(458): PhpCsFixer\Console\ConfigurationResolver->getFormat()
#4 C:\Users\Alex\AppData\Roaming\Composer\vendor\friendsofphp\php-cs-fixer\src\Console\Command\FixCommand.php(151): PhpCsFixer\Console\ConfigurationResolver->getReporter()
#5 C:\Users\Alex\AppData\Roaming\Composer\vendor\symfony in C:\dev\code\.php_cs on line 63
Here is the .php_cs file
<?php
$finder = Symfony\Component\Finder\Finder::create()
->files()
->in(__DIR__)
->exclude('vendor')
->exclude('resources/views')
->exclude('storage')
->exclude('public')
->notName("*.txt")
->ignoreDotFiles(true)
->ignoreVCS(true);
$fixers = [
'-psr0',
'-php_closing_tag',
'blankline_after_open_tag',
'double_arrow_multiline_whitespaces',
'duplicate_semicolon',
'empty_return',
'extra_empty_lines',
'include',
'join_function',
'list_commas',
'multiline_array_trailing_comma',
'namespace_no_leading_whitespace',
'no_blank_lines_after_class_opening',
'no_empty_lines_after_phpdocs',
'object_operator',
'operators_spaces',
'phpdoc_indent',
'phpdoc_no_access',
'phpdoc_no_package',
'phpdoc_scalar',
'phpdoc_short_description',
'phpdoc_to_comment',
'phpdoc_trim',
'phpdoc_type_to_var',
'phpdoc_var_without_name',
'remove_leading_slash_use',
'remove_lines_between_uses',
'return',
'self_accessor',
'single_array_no_trailing_comma',
'single_blank_line_before_namespace',
'single_quote',
'spaces_before_semicolon',
'spaces_cast',
'standardize_not_equal',
'ternary_spaces',
'trim_array_spaces',
'no_useless_else',
'unalign_equals',
'unary_operators_spaces',
'whitespacy_lines',
'multiline_spaces_before_semicolon',
'short_array_syntax',
'short_echo_tag',
'concat_with_spaces',
'ordered_use',
];
return Symfony\CS\Config\Config::create()
->fixers($fixers)
->finder($finder)
->setUsingCache(true);
I can run the file manually by going to the cmd prompt and running
php-cs-fixer fix .\Controller.php
And it does what it's supposed to, I think with a default .php_cs file.
Driving me bats. :)

Problem is we were trying to use an older version of php-cs-fixer and it didn't function correctly with our version of php.
Fix was to update to php-cs-fixer v2.*

Related

iLovePDF Library - Fatal error: Class 'Ilovepdf' not found

I was trying to compress PDF. I try my best to find out some library that can be free too for some limited purpose. I found out iLovePDF Library.
I try to get it done using composer and without composer too But not find any way to resolve it.
My Code:
<?php
require_once('vendor/autoload.php');
// require_once('vendor/ilovepdf/init.php');
$ilovepdf = new Ilovepdf('project_public_key','secret_key');
$myTask = $ilovepdf->newTask('compress');
$file1 = $myTask->addFile('file1.pdf');
$myTask->execute();
$myTask->download();
?>
Fatal error: Uncaught Error: Class 'Ilovepdf' not found in C:\xampp\htdocs\PHP Doc\E15\index.php:11 Stack trace: #0 {main} thrown in C:\xampp\htdocs\PHP Doc\E15\index.php on line 11
You need to use namespaces:
$ilovepdf = new \Ilovepdf\Ilovepdf('project_public_key','secret_key');
Or:
use \Ilovepdf\Ilovepdf;
$ilovepdf = new Ilovepdf('project_public_key','secret_key');
Thank You.
I resolved it by adding below line at the top of index.php
namespace Ilovepdf;

Fatal error: Uncaught Error: Class 'Spyc' not found in app/code/DeviceDetector/Yaml/Spyc.php

I am facing the issue with order placing on Magento ver. 2.2.2. After complete the payment when I will redirect to website https://domainname/paypal/express/placeOrder/ page and error display on that page.
Please check the error below,
Fatal error: Uncaught Error: Class 'Spyc' not found in
/public_html/app/code/DeviceDetector/Yaml/Spyc.php:17 Stack trace: #0
/public_html/app/code/DeviceDetector/Parser/ParserAbstract.php(155):
DeviceDetector\Yaml\Spyc->parseFile('/p...') #1
/public_html/app/code/DeviceDetector/Parser/ParserAbstract.php(243):
DeviceDetector\Parser\ParserAbstract->getRegexes() #2
/public_html/app/code/DeviceDetector/Parser/Bot.php(53):
DeviceDetector\Parser\ParserAbstract->preMatchOverall() #3
/public_html/app/code/DeviceDetector/DeviceDetector.php(623):
DeviceDetector\Parser\Bot->parse() #4
/public_html/app/code/DeviceDetector/DeviceDetector.php(587):
DeviceDetector\DeviceDetector->parseBot() #5
/public_html/app/code/MageWorx/OrdersBase/Observer/OrderPlaced.php(107):
DeviceDetector\DeviceDetector->parse() #6
/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72):
MageWorx\OrdersBase\Observer\OrderPlaced- in
/public_html/app/code/DeviceDetector/Yaml/Spyc.php on line 17
The error is seems related to the DeviceDetector plugin but I don’t know why this issue happen & I have check the particular lines mentioned in error but no solution found.
Please let me know how to resolve this issue. Thanks in Advance!
Can you add more details here, after what action this error start appear?
If you inject this class somewhere in constructor then I suggest you to run rm -rf generated/* because M2 dont update generated folder automatically if you change class that already generated in generation.
If its not work please share some context.

Use the smarty variable in smarty project php file

I have a smarty project, in a php file, I set a abc variable:
$smarty->assign('abc', '123');
now I can use the {$abc} in its corresponding .tpl file.
but now can I use the abc in php file?
I tried $smarty->abc and $smarty->$abc all can not access.
EDIT-01
If I use
$smarty->assign('abc', '1234');
$abc2 = $smarty->get_template_vars('abc');
I will get bellow error:
Fatal error: Uncaught Error: Using $this when not in object context in /Users/sof3/Desktop/smarty-test02/php/test.php:36 Stack trace: #0 {main} thrown in /Users/sof3/Desktop/smarty-test02/php/test.php on line 36
If your Smarty version is version 2. you can use:
$smarty->get_template_vars('abc')
but if your Smarty version is 3, you should use:
$smarty->getTemplateVars('abc')
more detail refer to: https://www.smarty.net/docs/zh_CN/language.syntax.functions.tpl

simplesamlphp throwing error after integrating with an APP

Anyone can help with this issue:
I have simplesamlphp instaled and tested successfully with my IdP and SP.
when I integrated the APP following the doc (step 6) https://simplesamlphp.org/docs/1.5/simplesamlphp-sp I started getting errors I will post bellow.
Here is my autoload.php:
require __DIR__.'/../vendor/autoload.php';
require_once('/var/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple ( 'default-sp' );
if ($as->isAuthenticated ()) {
//die ( 'ok' );
} else {
$param = array (
'ReturnTo' => 'http://10.128.240.181/'
);
$as->requireAuth ( $param );
}
$attributes = $as->getAttributes();
print_r($attributes);
$session = SimpleSAML_Session::getSessionFromRequest();
$session->cleanup();
Error output:
Feb 07 16:52:32 simplesamlphp WARNING [CL0a04f709] The class or interface 'SimpleSAML_Auth_Simple' is now using namespaces, please use 'SimpleSAML\Auth\Simple'.
PHP Notice: Undefined index: REQUEST_URI in /var/simplesamlphp/lib/SimpleSAML/Utils/HTTP.php on line 810
PHP Stack trace:
PHP 1. {main}() /var/www/Cachet/bootstrap/autoload.php:0
PHP 2. SimpleSAML\Auth\Simple->requireAuth() /var/www/Cachet/bootstrap/autoload.php:58
PHP 3. SimpleSAML\Auth\Simple->login() /var/simplesamlphp/lib/SimpleSAML/Auth/Simple.php:103
PHP 4. sspmod_saml_Auth_Source_SP->initLogin() /var/simplesamlphp/lib/SimpleSAML/Auth/Simple.php:161
PHP 5. sspmod_saml_Auth_Source_SP->authenticate() /var/simplesamlphp/lib/SimpleSAML/Auth/Source.php:193
PHP 6. sspmod_saml_Auth_Source_SP->startSSO() /var/simplesamlphp/modules/saml/lib/Auth/Source/SP.php:431
PHP 7. sspmod_saml_Auth_Source_SP->startSSO2() /var/simplesamlphp/modules/saml/lib/Auth/Source/SP.php:336
PHP 8. sspmod_saml_Auth_Source_SP->sendSAML2AuthnRequest() /var/simplesamlphp/modules/saml/lib/Auth/Source/SP.php:298
PHP 9. SAML2\HTTPRedirect->send() /var/simplesamlphp/modules/saml/lib/Auth/Source/SP.php:314
PHP 10. SAML2\Compat\Ssp\Container->redirect() /var/simplesamlphp/vendor/simplesamlphp/saml2/src/SAML2/HTTPRedirect.php:83
PHP 11. SimpleSAML_Utilities::redirectTrustedURL() /var/simplesamlphp/vendor/simplesamlphp/saml2/src/SAML2/Compat/Ssp/Container.php:52
PHP 12. SimpleSAML\Utils\HTTP::redirectTrustedURL() /var/simplesamlphp/lib/SimpleSAML/Utilities.php:276
PHP 13. SimpleSAML\Utils\HTTP::normalizeURL() /var/simplesamlphp/lib/SimpleSAML/Utils/HTTP.php:968
PHP 14. SimpleSAML\Utils\HTTP::getSelfURL() /var/simplesamlphp/lib/SimpleSAML/Utils/HTTP.php:889
****PHP Fatal error: Uncaught SimpleSAML_Error_UnserializableException: Unable to parse base url: http://localhost in /var/simplesamlphp/lib/SimpleSAML/Auth/Source.php:197****
Stack trace:
#0 /var/simplesamlphp/lib/SimpleSAML/Auth/Simple.php(161): SimpleSAML_Auth_Source->initLogin('http://10.128.2...', NULL, Array)
#1 /var/simplesamlphp/lib/SimpleSAML/Auth/Simple.php(103): SimpleSAML\Auth\Simple->login(Array)
#2 /var/www/Cachet/bootstrap/autoload.php(58): SimpleSAML\Auth\Simple->requireAuth(Array)
#3 {main}
thrown in /var/simplesamlphp/lib/SimpleSAML/Auth/Source.php on line 197
Anyone has an idea what could be the cause of this error ? I am a newbie in php and SAML,
I think there are two issues. The first one is:
Feb 07 16:52:32 simplesamlphp WARNING [CL0a04f709] The class or interface 'SimpleSAML_Auth_Simple' is now using namespaces, please use 'SimpleSAML\Auth\Simple'.
It seems you are following an old documentation and using a recent version of SimpleSAMLphp. You will have to use $as = new \SimpleSAML\Auth\Simple('default-sp'); instead of $as = new SimpleSAML_Auth_Simple ( 'default-sp' );
If you are using the latest stable version of SimpleSAMLphp, please follow https://simplesamlphp.org/docs/stable/simplesamlphp-sp
The second issue is
****PHP Fatal error: Uncaught SimpleSAML_Error_UnserializableException: Unable to parse base url: http://localhost in /var/simplesamlphp/lib/SimpleSAML/Auth/Source.php:197****
This is more related to the configuration (This is a wild guess). Can you provide more info on your web server (IIS/Apache/nginx)? I think IIS has some known issues: https://github.com/simplesamlphp/simplesamlphp/issues/540

use of class with namespace error

in api.php i use severall classes, with autoloaders. in include them like this
use \protoware\cms\Account as Account;
use \protoware\cms\Content as Content;
use protoware\cms\Count as Count;
include __DIR__ . '/vendor/autoload.php';
Local this works fine, when i upload it on a server i get this
Europe/Brussels] PHP Fatal error: Uncaught Error: Class 'protoware\cms\Content' not found in /data/vhosts/achielvolckaert.be/wwwroot/api.php:97
Stack trace:
#0 {main}
thrown in /data/vhosts/achielvolckaert.be/wwwroot/api.php on line 97
line 97 is the first line where i open a connection:
$content = new protoware\cms\Content();
$data = $content->get_content('medisch');
I have 0 clue how to fix this, i updated autloader, checked if all files were uploaded...
Try add a \ before class name, like $content = new \protoware\cms\Content(); or just $content = new Content() since you have a use statement.
If this class is a dependency, check if its correctly installed (inside your vendor folder, i.e.). Maybe run composer install?

Categories