Error with dredd hooks on Windows - php

I try use dredd with symfony on windows PC.
i do next:
i create folder dredd in symfony poject
app
dredd
src
vendor
e.t.c
in symfony composer.json i add
"ddelnano/dredd-hooks-php":"dev"
Next step, i create this dredd.yml
dry-run: null
hookfiles: ./hooks.php
language: php
sandbox: false
server: null
server-wait: 3
init: false
custom:
apiaryApiKey: 'apikey '
apiaryApiName: 'apiname'
names: false
only: []
reporter: apiary
output: []
header: []
sorted: false
user: user:pass
inline-errors: true
details: true
method: []
color: true
level: info
timestamp: true
silent: false
path: []
hooks-worker-timeout: 5000
hooks-worker-connect-timeout: 1500
hooks-worker-connect-retry: 500
hooks-worker-after-connect-wait: 100
hooks-worker-term-timeout: 5000
hooks-worker-term-retry: 500
hooks-worker-handler-host: localhost
hooks-worker-handler-port: 61321
config: ./dredd.yml
blueprint: test.apib
endpoint: 'someendpoint'
and another needed file.
and dredd response
error: PHP hooks handler command not found: dredd-hooks-php Install
php hooks handler by running: $ composer require
ddelnano/dredd-hooks-php --dev
Why it does not work? What am I doing wrong?
P.S. sorry for my english.

As of now, Dredd is not officially supported on Windows. However, it should install and should work well as far as you don't need other than JavaScript hooks. Any other hooks do not work at the moment.
Support for Windows is on the roadmap though - https://github.com/apiaryio/dredd/issues/204

Related

Log from Symfony to php://stdout shows log messages in my console commands

I am running a docker container with the official php:7.3.3-apache tag. I have Symfony 4 installed with monolog enabled.
Normally monolog uses the var/dev.log, var/prod.log and var/test.log to write its logs but you can change the configuration to php://stdout or php://stderr to send the logs to the docker container.
My monolog.yaml file looks like:
monolog:
handlers:
main:
type: stream
path: "php://stdout"
level: debug
channels: ["!event"]
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]
And it sends the logs properly from the website, however when I run a command using the php bin/console command I get the logs right on the screen, for example:
$ php bin/console cache:clear
[2019-06-24 14:29:19] doctrine.DEBUG: SELECT h0_.id AS id_0, h0_.name AS name_1, h0_.value AS value_2, h0_.description AS description_3 FROM hpa_configuration h0_ [] []
[2019-06-24 14:29:19] php.INFO: User Deprecated: The "Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" class is deprecated since Symfony 4.2, use "Symfony\Component\Console\Command\Command" with dependency injection instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand\" class is deprecated since Symfony 4.2, use \"Symfony\\Component\\Console\\Command\\Command\" with dependency injection instead. at /var/www/html/hpa/vendor/symfony/framework-bundle/Command/ContainerAwareCommand.php:18)"} []
// Clearing the cache for the dev environment with debug ......
How can I log properly from the website and commands?
Change php://stdout to php://stderr

Codeception Acceptance Tests not working

everyone!
I have been trying to configure Codeception 2.3.6 with Laravel 5.3.30 running on PHP 7.0.23 powered by WAMP 3.1.0. My functional test cases are running fine, but when I try to run my acceptance test cases, a new chrome window opens and then closes without doing anything.
The output in the HTML Report is Codeception Results OK(0s), while the output on the command line is:
WelcomeCept: Perform actions and see result (0.00s)
Time: 3.24 seconds, Memory: 22.75MB
OK (1 test, 0 assertions)
HTML report generated in file://D:\wamp\www\myApp\tests/_output\report.html
First I start ChromeDriver with the command
chromedriver --url-base=/wd/hub
Then I start Selenium Standalone Server 3.13.0 with the command:
java -Dwebdriver.chrome.driver="chromedriver" -jar selenium-server-standalone-3.13.0.jar -port 4445
Then I run my acceptance test suite which contains a single test file, with the command:
call vendor/bin/codecept run acceptance --html
My acceptance.suite.yml is:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: http://lcms.com/
window_size: false # disabled in ChromeDriver
port: 9515
browser: 'chrome'
restart: true
wait: 200
capabilities:
unexpectedAlertBehaviour: 'accept'
webStorageEnabled: true
javascriptEnabled: true
- Laravel5:
part: ORM
cleanup: false # can't wrap into transaction
environment_file: .env
- \Helper\Acceptance
My WelcomeCept.php file, just for testing the configuration, is:
<?php
class WelcomeCept
{
public function welcomeTest(AcceptanceTester $I)
{
$I->wantTo('perform actions and see result');
}
}
Please review my workflow and let me know if I'm doing things incorrectly or am missing something.
Thanks!
Update: Same thing is happening using GeckoDriver or PhantomJS in WebDriver mode. The tests are passing with OK but not performing any actions.
Solved! I tried WelcomeCest instead of WelcomeCept and things have fallen into place.

How do I configure REST module in Codeception to use browserstack?

I am writing acceptance codeception tests on a web application. It will require me to check headers, specifically response codes. I have found that the codeception REST module can be used, but it appears to require phpbrowser. I am required though to use browserstack. How would the configuration look using browserstack as aposed to phpbrowser.
My acceptance.suite.yml is currently set up like:
chrome-dev:
modules:
enabled:
- WebDriver
- \Helper\
config:
WebDriver:
url: 'https://XXXXXXXXXXXXXXXXXX.com'
host: 'XXXXXXXX#XXXXXXXX.com:XXXXXXXXXX.browserstack.com'
port: 80
browser: 'chrome'
window_size: maximize
capabilities:
'os': 'Windows'
'os_version': '10'
'browser_version': '57'
'acceptSslCerts': true
'resolution': '1600x1200'
'browserstack.chrome.enablePopups': true
'browserstack.chrome.allowAllCookies': true
My question here is how would I insert the REST module without using phpbrowser? It appears that it may be required, but does anybody know otherwise?
It is impossible - WebDriver and REST modules are incompatible.

Run PHP CS fixer with GrumPHP

I'm using GrumPhp to sniff my commit in my symfony project: https://github.com/phpro/grumphp
Here is my config:
parameters:
git_dir: .
bin_dir: vendor/bin
tasks:
phpcsfixer:
config_file: ~
config: sf23
fixers: [psr2, symfony, indentation]
level: psr2
verbose: true
My question is:
Is there a way for Grumphp to automatically run php-cs-fixer when I commiting?
Yes there is!
https://github.com/phpro/grumphp/blob/master/doc/tasks.md
Since your post is a bit older here is the new updated doc, but you can still use version one! https://github.com/phpro/grumphp/blob/master/doc/tasks/php_cs_fixer2.md
You could try out this configuration but it's phpcsfixer version2!:
# grumphp.yml
parameters:
bin_dir: "./vendor/bin"
git_dir: "."
hooks_dir: ~
hooks_preset: local
stop_on_failure: false
ignore_unstaged_changes: false
process_async_limit: 10
process_async_wait: 1000
process_timeout: 60
ascii:
failed: grumphp-grumpy.txt
succeeded: grumphp-happy.txt
tasks:
phpcsfixer2:
allow_risky: false
cache_file: ~
config: ~
rules: ['#Symfony']
using_cache: true
path_mode: ~
verbose: true
Your config looks fine, what's the output ?
Do you have the cs fixer installed and configured the grumPHP config to the path of your CS fixer?
https://github.com/FriendsOfPHP/PHP-CS-Fixer#usage
GrumPHP always run php-cs-fixer with the --dry-run argument and this behavior is not configurable. You can read why here: https://github.com/phpro/grumphp/issues/110
But there's a way to automatically run php-cs-fixer: you have to install GrumPHP Extra Tasks and replace phpcsfixer2 with php_cs_auto_fixerv2 in your "grumpphp.yml" file.
Be aware that as of today GrumPHP Extra Tasks is not compatible with the latest version of GrumPHP but up to 0.17.2.

Using knp snappy bundle to generate pdf - symfony2

I'm new to symfony2 and very to use external libraries.
I want to use the KNP Snappy Bundle, my first third party bundle.
I did exactly that is told in the git link.
{
"require": {
"knplabs/knp-snappy-bundle": "dev-master"
}
}
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
//...
new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
app/config/config.yml
knp_snappy:
pdf:
enabled: true
binary: /usr/local/bin/wkhtmltopdf
options: []
image:
enabled: true
binary: /usr/local/bin/wkhtmltoimage
options: []
Then I added following line in ACME welcome controller to test
$this->get('knp_snappy.pdf')->generate('http://www.google.fr', '/Symfony/file.pdf');
It says The exit status code '1' says something went wrong:
stderr: "The system cannot find the path specified.
"
stdout: ""
command: /usr/local/bin/wkhtmltoimage --format "jpg" "http://www.google.fr" "/Symfony/file.pdf".
I tried
$this->get('knp_snappy.pdf')->generateFromHtml(
$this->renderView(
'AcmeDemoBundle:Welcome:index.html.twig'),
'/Symfony/file.pdf'
);
It shows The exit status code '1' says something went wrong:
stderr: "The system cannot find the path specified.
"
stdout: ""
command: /usr/local/bin/wkhtmltopdf --lowquality "C:\Windows\TEMP\knp_snappy530da4525584b8.92211088.html" "/Symfony/file.pdf".
What I'm missing? Do I need to install anything ? Please describe how can I run it and generate a proper pdf????? I searched, I'm guessing I need to install wkhtmltoimage etc. But from where and how?
you can also manage wkhtmltopdf with composer too, I did it in a recent project:
in your composer.json you can add:
"h4cc/wkhtmltopdf-amd64": "0.11.0-RC1"
and in your config.yml:
binary: %kernel.root_dir%/../vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64
Few months later, but here is what helped me.
I put the path to wkthmltopdf folder in escaped double quotes.
knp_snappy:
pdf:
binary: "\"C:/Program Files (x86)/wkhtmltopdf/wkhtmltopdf.exe\""
You can do one of these
1- Update your config.yml
pdf:
enabled: true
binary: wkhtmltopdf
options: []
And update your windows environment PATH with path/to/my/wkhtmltopdf
2- Or set the path directly in config.yml
pdf:
enabled: true
binary: /path/to/my/wkhtmltopdf
options: []

Categories