Class 'Firebase\Jwt\Jwt' not found YII2 - firebase

composer require firebase/php-jwt:^2.2
install is OK
So
use \Firebase\JWT\JWT;
$key = "example_key";
$payload = array(
"iss" => "http://example.org",
"aud" => "http://example.com",
"iat" => 1356999524,
"nbf" => 1357000000
);
$jwt = JWT::encode($payload, $key);
Error
Class 'Firebase\Jwt\Jwt' not found
Help me!!!
Detail Error
Dettaglio Errore
Thank You

The code in index.php doesn't look like code you wrote here. Try to use \Firebase\JWT\JWT; in index.php.
Also PHP namespaces are case sensitive, so make sure you wrote it correct or use IDE's autocomplete.

Related

How to replace silex in a project and adapt it to php8

I have this in my project php.
$app = new Silex\Application();
$app->register(new DerAlex\Silex\YamlConfigServiceProvider(realpath(__DIR__ . '/config/settings.yml')));
$app->register(new \Knp\Provider\MigrationServiceProvider(), array(
'migration.path' => __DIR__.'/../migration',
));
I need to update the code to use php8.
All package are abandoned / archived.
I could replace silex/silex by spryker/silexphp.
I dont know how to replace this package to get settings.yml configutarion.
DerAlex\Silex\YamlConfigServiceProvider
Someone knows how can i do this?

Laravel PHP Unit Testing

I am just testing my laravel app with phpunit
When i run vendor/bin/phpunit i am getting error like below Error: Call to undefined method ExampleTest::assertStatus()
Below is the code i was trying to execute
$response = $this->json('POST', '/users', ['customer_name' => 'Ratke-Harris']);
$response
->assertStatus(200)
->assertExactJson([
'created' => true,
]);
As per the laravel docs , even there they have mentioned the same example. I don't understand why it is throwing error.
Any ideas ? Please.
Change ->assertStatus(200) to ->assertResponseStatus(200)
Just change use PHPUnit\Framework\TestCase with use Tests\TestCase in the top of your test class:))

wkhtmltopdf works in command mode but not in Symfony2 bundle (knp_snappy)

I am generating PDF reports about the bundle knp_snappy, as it says in the title, so wkhtmltopdf command works perfectly in command mode but it does in the bundle, I get the following error:
The exit status code '127' says something went wrong:
stderr, "PROT_EXEC | PROT_WRITE failed.
I understand it is something related to permissions but do not know what I have to change to make it work.
my config.yml
knp_snappy:
pdf:
enabled: true
binary: "/usr/bin/wkhtmltopdf"
options: []
My controller:
$html = $this->renderView('PanelBundle:Default:hotel-booking-summary.pdf.html.twig', array(
'summary' => $summary,
'agency' => $agency
));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
I hope you can help me, greetings and thank you very much.
pls show
ls -la /usr/bin/wkhtmltopdf
Actually you can try set permissions something like
sudo chown %your_ssh_user%:%your_www_group% /usr/bin/wkhtmltopdf

Need to pull fields from an issue in Sitecore

I'm working with SiteCore and I need to pull some data out of the software via either that API or the SQL database using a PHP script. The reason I say both are possible is because even if the database changes later on, that doesn't matter to me.
Anyway...
I'm trying to pull any data fields that I can get from a particular issue. This is my SOAP code so far, and it connects to the service and such, but the return isn't what I need...
try
{
$client = new SoapClient('http://localhost:8083/sitecore/shell/webservice/service.asmx?WSDL');
$credentials = array('Password' => 'mypassword','Username' => 'sitecore\myusername');
$Current_Issue = array(
'id' => '{043B69BA-3175-4184-812F-C925CE80324E}',
//'language' => 'en',
//'version' => '1',
//'allFields' => 'true',
'databaseName' => 'web',
'credentials' => $credentials
);
$response = $client->GetItemMasters($Current_Issue);
print_r($response);
}
catch(SoapFault $e)
{
echo $e->getMessage();
}
catch(Exception $e)
{
echo $e->getMessage();
}
This is my output:
stdClass Object
(
[GetItemMastersResult] => stdClass Object
(
[any] => <sitecore xmlns=""/>
)
)
ANY help is appreciated. If anybody knows an example SQL query that I can use, that would be just as useful as an alternative method.
Thanks
If you are running Sitecore 6.5 / 6.6 you may want to take a look at the Sitecore Item Web API which was released yesterday (5/11/12).
http://sdn.sitecore.net/Products/Sitecore%20Item%20Web%20API.aspx
This allows you to perform RESTful operations against Sitecore items without the need for the old web service / SOAP interface. Using this module you can receive a JSON representation of a Sitecore item or collection of items and even post back changes. You may find it easier to work with :)
If you have to use the SOAP interface, are you sure that your items are published ? Try changing the databaseName -> 'master' and see if you get any results. Other things to check are the permissions of the user credentials you are using.

How to generate translation file for a custom Drupal 7 module?

I'm using CentOS 5.5 Linux (without X), PHP 5.3 and Drupal 7.0.
The core language of my site is Russian (not English)!
I've created a game.info and the following game.module which generates 3 blocks for the front page:
function game_block_info() {
return array(
'game_main' => array(
'info' => t('Set FlashVars and show the flash game.'),
'cache' => DRUPAL_NO_CACHE,
),
'game_winner' => array(
'info' => t('Show the winner of the last week.'),
'cache' => DRUPAL_NO_CACHE,
),
'game_leader' => array(
'info' => t('Show the leader of the current week.'),
'cache' => DRUPAL_NO_CACHE,
);
}
function game_block_view($block_name = '') {
global $user;
if ($block_name == 'game_main') {
if (user_is_logged_in()) {
$content = t('User is logged in.');
} else {
$content = t('User is an anonymous user.');
}
drupal_set_message("<pre>$output</pre>\n");
return array(
'subject' => t('Main Game'),
'content' => $content,
);
} else if ($block_name == 'game_winner') {
....
} else if ($block_name == 'game_leader') {
....
}
}
It works ok, but I need all strings to be in Russian and do not want to hardcode them into my game.module file.
Do I need to create the 3rd file called game.po and add it to the game.info?
How can I create a .po file? I would prefer a simple editing of that file if possible, without obscure tools.
I've also tried a tool:
# xgettext -n game/game.module --keyword=t
xgettext: warning: file `game/game.module' extension `module' is unknown; will try C
game/game.module:87: warning: unterminated character constant
game/game.module:100: warning: unterminated character constant
These should be the steps:
To generate the .pot file, install the module Translation template extractor
Go to the "Extract strings" tab on the Locale administration interface, select your module and submit the form. You will get one single template file generated.
Then you can translate the strings with a tool like Poedit (http://www.poedit.net).
When you are done, files should be copied to a "translations" sub-folder in the module folder, so they are automatically imported by Drupal when installing your game module.
Please, give feedback and tell what problems did you have. Thanks

Resources