Trying to install CodeCeption with Laravel framework 5.6
I am getting this error.
Steps i followed to install are
1. composer require codeception/codeception --dev
2. php ./vendor/bin/codecept bootstrap
The error i am getting is
Fatal error: Declaration of Codeception\Test\Unit::getDependencies() must be compatible with PHPUnit\Framework\TestCase::getDependencies(): array in /vendor/codeception/codeception/src/Codeception/Test/Unit.php on line 14
Can someone tell how to fix this or downgrade and get it work with Laravel 5.6?
This was just fixed in codeception/codeception version 2.4.5, so run composer update, and the error should no longer be happening.
From the changelog (emphasis mine):
2.4.5
Fixed PHPUnit 7.2 compatibility.
Introduced RunBefore extension to execute scripts before running tests. See #5049 by #aashmelev.
[Db] Added two options for MySQL by #bangertz
ssl_cipher - list of one or more permissible ciphers to use for SSL encryption
ssl_verify_server_cert - disables certificate CN verification
[Db] Always disconnect before connect when reconnect is set. By #ashnazg
[Db] More explicit PDO closing upon destruction and close opened transactions by #ashnazg.
[Recorder Extension] Improved error logging by #OneEyedSpaceFish. See #5101
[Lumen] Fixed file uploads via REST module. By #retnek.
Fixed: function getMetadata() may not exist, results in fatal error. See #4913 by #marcovtwout
In Codeception/Test/Unit.php line no 133, change the getDependencies function to have a array return type. : array
After the change the getDependencies function should look like this.
public function getDependencies(): array
{
$names = [];
foreach ($this->getMetadata()->getDependencies() as $required) {
if ((strpos($required, ':') === false) and method_exists($this, $required)) {
$required = get_class($this) . ":$required";
}
$names[] = $required;
}
return $names;
}
Related
I want to run PHP Thread class code on Windows. I tried some manual installation guides like e.g. this one but they didn't work. PHP cannot load the pthreads DLL even though the file exists at this location:
PHP Warning: PHP Startup: Unable to load dynamic library 'php_pthreads.dll' (tried: C:\xampp\php\ext\php_pthreads.dll (The specified module could not be found), C:\xampp\php\ext\php_php_pthreads.dll.dll (The specified module could not be found)) in Unknown on line 0
I downloaded php_pthreads-3.1.6-7.0-ts-vc14-x64.zip. My PHP version is: PHP 8.1.6 (cli) (built: May 11 2022 08:55:59) (ZTS Visual C++ 2019 x64). Generally I'm still not entirely sure which pthread version to select since there are many choices here. Are any of them even going to work since they seem a bit outdated? My phpinfo says:
Can I maybe just use Windows threads since they are already available on my system?
After the pthreads installation, when I run my Thread class example code
<?php
class AsyncOperation extends Thread
{
public function __construct($arg)
{
$this->arg = $arg;
}
public function run()
{
if ($this->arg) {
printf("Hello %s\n", $this->arg);
}
}
}
$thread = new AsyncOperation("World");
if ($thread->start())
$thread->join();
?>
I still get the warning above and the following error:
PHP Fatal error: Uncaught Error: Class "Thread" not found
What am I doing wrong? Is there maybe a way to do it with less "manual" effort in e.g. 1 composer command or an easier way to get threading working?
I'm trying the following setup and am getting this error:
\nFatal error: Uncaught Error: Found top-level code in /home/user/code/xhp-simple/src/example.php:7\nStack trace:\n#0 (): main()\n#1 {main}
Setup:
composer.json
{
"require": {
"hhvm/hhvm-autoload": "^3.1",
"facebook/xhp-lib": "^4.0"
}
}
src/index.hack
use type Facebook\XHP\HTML\div;
// require_once(__DIR__."/../vendor/hh_autoload.hh"); // also tried here instead of in main
<<__EntryPoint>>
function main(): void {
require_once(__DIR__."/../vendor/hh_autoload.hh");
echo <div>{1 + 2}</div>;
}
hh_autoload.json
{"roots": ["src/"]}
run command:
hhvm -m server -p 8080 -d hhvm.server.default_document=./src/example.hack
I have hhvm v 4.83.1 installed
I think that you're running into the fact that hhvm-autoload hasn't caught up with the recent restrictions to top-level code. In particular, where require_once seems to no longer be allowed at the top level. With your hh_autoload.json, hhvm-autoload generates this hh_autoload.hh:
<?hh // partial
require_once(__DIR__.'/autoload.hack');
Facebook\AutoloadMap\initialize();
Where I believe that require_once is illegal. If you place this code in your main, it should work. I tested this with no problems on HHVM 4.84.0:
// src/index.hack
use type Facebook\XHP\HTML\div;
<<__EntryPoint>>
async function main(): Awaitable<void> {
require_once(__DIR__.'/../vendor/autoload.hack');
Facebook\AutoloadMap\initialize();
echo await (<div>{1 + 2}</div>)->toStringAsync();
}
$ # run with:
$ hhvm src/index.hack
Also note that all rendering is async now with XHP-lib, so you can't just echo XHP objects directly; instead:
Calls to $xhp->toString() need to be updated to $xhp->toStringAsync().
I've just noticed the updated README on hhvm-autoload, where indeed hh_autoload.hh has been phased out and you need to need to generate the autoload map yourself (emphasis mine):
Replace any references to vendor/autoload.php with vendor/autoload.hack and call Facebook\AutoloadMap\initialize()
I've installed the current version of directus on my VPS (Debian 10, PHP 7.3, Apache 2.4.38).
When running the browser-based install, an error appears in the /logs saying:
[2020-02-27 20:31:59] api[].ERROR: ParseError: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /var/www/clients/client0/web16/web/vendor/symfony/translation-contracts/TranslatorTrait.php:44
For me, it sounds like if it was a wrong PHP version, but PHP 7.3 is running.
I don't know whether this is important, but after ignoring this, on the page where you enter the database connection parameter, the POST to /server/projects returns with Error 500 "Internal Server Error".
I cannot find any log entry.
How can I find the reason for the 500?
Is it possible to configure the application without the browser-based installation?
Edit
Switched back from master to v8.5.5 and in this source code, there is a trans function:
/**
* {#inheritdoc}
*/
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
{
if (null === $id || '' === $id) {
return '';
}
if (!isset($parameters['%count%']) || !is_numeric($parameters['%count%'])) {
return strtr($id, $parameters);
}
So there is indeed a type ?string.
My PHP version should be able to handle this, IMO. But before, I had Debian 9 with PHP 7.0 where I had the same problem and which was the reason to upgrade Debian from 9 to 10.
Is it possible that a compile-cache from Debian 9 is still present?
But I suppose this is not the main problem. My problem is that I receive an error 500 and besides the 500-log-entry in apache error.log, there is nothing I can see to diagnose this issue.
A handy way to find syntax errors when error reporting and logs don't yield anything is to try and run the script through command line using the lint flag, e.g.
php -l path/to/file.php
TranslatorTrait.php seems to be corrupted, because line #44 actually should be:
public function trans($id, array $parameters = [], $domain = null, $locale = null)
So obviously, there should be no unexpected ?. Try to refresh composer dependencies with:
rm -rf vendor/*
And then:
composer clearcache && composer install
I am deploying a symfony2 application to a server where php intl extension is not enabled. I have no say in this.
The answer to this question suggests a solution:
Possible to disable intl requirement for Symfony?
I have put the "symfony/intl": "3.0.*#dev" in my composer.json and everything updates fine. Must I do anything more to activate/enable it? In AppKernel like with bundles?
Now I get the following errors when I run check.php on deployment server:
PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Extension intl does not exist' in /web/folk/eirik/030476/releases/20150528181203/app/SymfonyRequirements.php:658
Stack trace:
#0 /web/folk/eirik/030476/releases/20150528181203/app/SymfonyRequirements.php(658): ReflectionExtension->__construct('intl')
#1 /web/folk/eirik/030476/releases/20150528181203/app/check.php(6): SymfonyRequirements->__construct()
#2 {main}
thrown in /web/folk/eirik/030476/releases/20150528181203/app/SymfonyRequirements.php on line 658
I look at line 658 in SymfonyRequirements.php and find:
if (class_exists('Locale')) {
if (defined('INTL_ICU_VERSION')) {
$version = INTL_ICU_VERSION;
} else {
$reflector = new ReflectionExtension('intl');
ob_start();
$reflector->info();
$output = strip_tags(ob_get_clean());
preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
$version = $matches[1];
}
$this->addRecommendation(
version_compare($version, '4.0', '>='),
'intl ICU version should be at least 4+',
'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).'
);
}
I don't know much about this stuff, but I assume
new ReflectionExtension('intl') requires the intl exension to be enabled in php, which is no option for me.
But what is INTL_ICU_VERSION? And why is it not defined? And why won't the symfony/intl component fix this for me?
And btw
if (class_exists('Collator')) {
$this->addRecommendation(
null !== new Collator('FR_fr'),
'intl extension should be correctly configured',
'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.'
);
}
I have also changed 'FR_fr' to 'en' here, this was an error given by check.php that disappeared when I made the change.
If you take a look into the file check.php you are running you'll see that it does not load the Composer autoloader therefore it makes no difference whether you have installed that Symfony Intl component or not, it'll keep failing because it's looking for a required extension that is not there. The SO question you linked does mention the problem got solved but it doesn't say that the check passed.
If that extension was your problem with your Symfony installation and the only locale you needed is "en" than the problem should have gone away already after you installed the Symfony Intl drop in replacement. Although if you want to run the check for other problems you can comment out those lines so the script can finish. Don't worry that script is totally decoupled from the framework, you can even delete it when you are done.
If you are using Capistrano for the deployment and you are running those checks on every deployment you might want to disable that as well, or customise that script for your needs.
I am trying to use the HttpRequest class which should be in the PECL_HTTP extension of php.
I have php5 and used the following to install pecl_http.
sudo pecl install pecl_http
pecl/pecl_http is already installed and is the same as the released version 2.0.1
install failed
After that i enter into my php.ini:
[PHP]
extension=http.so
[...]
Then i restart my apache2 server, and try using the HttpRequest class, but it gives me the following error:
PHP Fatal error: Class 'HttpRequest' not found
What are possible error's i might have missed?
UPDATE: (Changed the title)
The Extension is not shown in phpinfo(), i set
extension=http.so
And checked if the http.so file is in my extension_dir. I really don't know how to make php recognise the extension.
UPDATE 2:
I managed to install extension, but the class still does not exist.
For others, i had to reference the other extensions pecl_http needs. (For me: propro.so, raphfr.so)
UPDATE 3:
I did not manage to make the Class visible, the answers below show some approaches with other classes.
I solved this issue by using CURL.
You have installed the new version of the extension which uses a completely different API. I still don't know how it works, but I will update my answer one I know. The Documentation of the new version is to be found at http://devel-m6w6.rhcloud.com/mdref/http.
To Install the old version, first uninstall the new verion and then execute
pecl install http://pecl.php.net/get/pecl_http-1.7.6.tgz
UPDATE: here are two examples from the documentation, both should work well:
one request (can be found at http://devel-m6w6.rhcloud.com/mdref/http/Client/enqueue):
<?php
(new http\Client)->enqueue(new http\Client\Request("GET", "http://php.net"),
function(http\Client\Response $res) {
printf("%s returned %d\n", $res->getTransferInfo("effective_url"), $res->getResponseCode());
return true; // dequeue
})->send();
multiple requests (can be found at http://devel-m6w6.rhcloud.com/mdref/http/Client/once):
<?php
$client = new http\Client;
$client->enqueue(new http\Client\Request("HEAD", "http://php.net"));
$client->enqueue(new http\Client\Request("HEAD", "http://pecl.php.net"));
$client->enqueue(new http\Client\Request("HEAD", "http://pear.php.net"));
printf("Transfers ongoing");
while ($client->once()) {
// do something else here while the network transfers are busy
printf(".");
// and then call http\Client::wait() to wait for new input
$client->wait();
}
printf("\n");
while ($res = $client->getResponse()) {
printf("%s returned %d\n", $res->getTransferInfo("effective_url"),
$res->getResponseCode());
}
In both examples you can use $res->getBody() to return the body of the response.
I couldn't test these examples but I have heard of other people that they work.
I had the same problem and solved it by arrange the order in wich extensions are loaded in php.ini
All my other extensions was loaded using their own .ini files in /etc/php5/mods_available.
In my apache2 error.log I noticed that json_decode was needed by http.so to load.
I created a file for http (http.ini) and a symlink in /etc/php5/apache/conf.d with a higher prefix than json.
my http.ini
; configuration for php http module
; priority=50
extension=raphf.so
extension=propro.so
extension=http.so
use the new pecl_http.2.0.6 like this
new http\Message();
or extend in your own class as extends http\Message