behat.yml in app/config instead of root directory - php

I installed behat with mink and selenium2-driver for my Symfony2 project.
Is it possible to use the /app/config/behat.yml instead of the /behat.yml file?
I searched on google but I can't find anything else this command.
php bin/behat --config app/config/behat.yml
But the command isn't working either.
I think there must be a config-path in composer.json.

Yes, you can configure which config file you want to use. Look at this part of the doc.
http://docs.behat.org/guides/7.config.html#paths
What error do you get when running your command?
php bin/behat --config app/config/behat.yml
This error?
[RuntimeException]
Context class not found.
Maybe you have provided a wrong or no `bootstrap` path in your behat.yml:
http://docs.behat.org/guides/7.config.html#paths
If that's the case, I think if might be because you need to specify where to find the features in your behat.yml file.
Now you moved the file to /app/config/behat.yml, the related path from behat.yml to the feature directory has changed, so you should add the following to the file:
default:
paths:
features: ../features/
bootstrap: ../features/bootstrap

Related

Using encore webpack with symfony project

I'm using the Encore/Webpack in my Symfony project, but Im having troubles with the installation.
I'm following the official guide: Link to official guide
My project folder:
projectname
---/app
---/assets
/css
/global.scss
/js
/main.js
...
---/node_modules
/.bin
/encore
...
---/web
/build
etc
I was following
Create a new file called webpack.config.js at the root of your
project.
It looks like:
projectname
...
webpack.config.js
I filled it with the example code. Afterwards I wanted to 'build' the assets with the command encore dev on path: projectname\node_modules\.bin
When I do this, I get the following error code:
Running webpack ...
No configuration file found and no output filename configured via CLI option.
A configuration file could be named 'webpack.config.js' in the current directory.
Use --help to display the CLI options.
I have no idea what I'm doing wrong. When I move the webpack.config.js to the .bin folder.. that part works, but than the build doesn't work, because it wants to install the files into .../.bin/build/ which is not correct. I want it into projectname/build like the example.
try this commend it's work for me
install webpack-notifier#^1.6.0 --save-dev

How to set php executable path php.validate.executablePath in vscode when php is set inside docker container?

I have a development environment based in docker.
Everytime that I open VSCode I get this message:
Cannot validate since no PHP executable is set. Use the setting
'php.validate.executablePath' to configure the PHP executable.
Somebody know how to set php.validate.executablePath in this case?
I have no idea how to do it.
Here is a screenshot.
Don't forget to escape \
You don't have to add it to the Path
For linux users:
if you don't have PHP installed then first download, then in terminal type
$ whereis php
and it will show path for php executable (It will be either in /usr/bin/php or usr/local/bin/php) which you can copy from terminal.
In VScode goto settings.json file and paste
php.validate.executablePath: /usr/bin/php
In my case using XAMPP is like this
"php.validate.executablePath": "C:/xampp/php/php.exe"
hope that answer your question
Sure, easy. Just follow what it's says.
Go to File> Preferences > Settings ... it will open the settings.json file.
add the following code:
{"php.validate.executablePath": "Here you put your PHP.exe path"}
You have to know where te PHP.exe file is in your computer, search in the php>bin folder.
Hope it works for you
I had the same problem but found the fix here.
In Windows:
Go To System Properties
Go To Advanced Tab
Click "Environment Variables"
Select Path
Add a new path that points to your php 7 executable:
My case, I'm using Laragon, so you should search where is your php.exe.
By VSCode just add.
"php.executablePath": "C:\\laragon\\bin\\php\\php-7.2.19-Win32-VC15-x64\\php.exe"
on settings.json.
VSCode
Linux Users:
Step 1:
In your terminal type
whereis php
In my case "php: /opt/lampp/bin/php"
Step 2:
{
"php.validate.executablePath": "/opt/lampp/bin/php"
}
Download PHP, in my case, I downloaded from here:
http://windows.php.net/download/
Copy and paste the files to a location on your computer, and set the path:
"php.validate.executablePath": "C:/php/php.exe"
"php.validate.executablePath": "C:/php/php.exe" wont work due to incorect escaping
try this;
"php.validate.executablePath": "C:\\php\\php.exe"
If you get this on windows in VS code click on the blue 'open settings' button. Near the bottom of the screen this opens there's a link to enter the settings, click this to open the settings.json file. Edit the file to look like this:
{
"php.executablePath" : "C:/php-7.4.2-nts-Win32-vc15-x64/php.exe",
"php.validate.executablePath" : "C:/php-7.4.2-nts-Win32-vc15-x64/php.exe"
}
where C:/php-7.4.2-nts-Win32-vc15-x64 is the path to your PHP dir
I don't know if this helps but I ran into the same problem with the extension PHP Intelephense in Visual Studio Code. What I did is read the instructions so the extension could work properly. So I disabled PHP Language Features by searching "#builtin PHP" in the extensions. Also, other (3rd party) PHP extensions that provide similar functionality should also be disabled for best results. Finally, I added glob patterns for non-standard PHP file extensions to the files.associations setting. For example: "files.associations": { "*.module": "PHP" }
Doing this made the error go away. I'm new to PHP too, let me know if this is the correct way of solving this problem with PHP Intelephense.
If you're using VScode and have installed Php through MAMP, the default path should be:
C:/MAMP/bin/php/php7.4.1/php.exe
/ not \
Regarding the docker-specific revision of the question, I found this thread in the VS Code PHP Intellisense git repo issue that explains how to create a wrapper script. It will involve mapping volumes, though, so take that into account.
https://github.com/felixfbecker/vscode-php-intellisense/issues/150#issuecomment-330374124
I have ubuntu and XAMPP.
The following worked for me.
Press CTRL + P
Type settings.json and hit ENTER.
Add the following line in settings.json
{
...
"php.validate.executablePath": "/opt/lampp/bin/php",
...
}
Make sure to proper syntax.
I simply used double forward slashes and it worked, like so:
"php.validate.executablePath": "C:\\xampp\\php\\php.exe",
Unix / Linux / Mac / WSL ,
Step 1 : Find PHP path
whereis php
Response will show you where your php directories are.
user#User:~$ whereis php
php: /usr/bin/php /usr/bin/php8.0 /usr/bin/php8.1 /usr/lib/php /etc/php /usr/share/php8.0-opcache
/usr/share/php8.0-xml /usr/share/php8.1-curl /usr/share/php8.1-opcache /usr/share/php8.0-gd
/usr/share/php7.0-gd /usr/share/php7.0-common /usr/share/php8.0-readline /usr/share/php8.0-mysql
/usr/share/php8.0-zip /usr/share/php8.1-mbstring /usr/share/php8.1-xml /usr/share/php8.0-mbstring
/usr/share/php8.0-common /usr/share/php8.0-curl /usr/share/php8.1-readline /usr/share/php8.1-common
/usr/share/man/man1/php.1.gz
Step 2 : Configure VS-Code
Go to -> "Preference -> Settings"
Search for -> "php path"
Then click -> "Edit in settings.json"
In my case I had multiple.So I chose the one I wanted from the available versions and my VS-Code looked like this
"php.validate.executablePath": "/usr/bin/php8.1",
IF using Laragon...Dont forget to change \ to /
"php.executablePath": "C:/laragon/bin/php/php-7.4.5-Win32-vc15-x64/php.exe",
Go to 'Preference' -> 'Settings'
Search for> php path
Then click Edit in settings.json
Then just put your directory with (DOUBLE Backslash).
Here is an example of mine:
C:\\php\\php.exe
Here is the format:
drive:\\folder_name\\php.exe
This should fix the problem.
php.validate.executablePath in laragon
In my case using laragon is like this
"php.validate.executablePath": "C:\\laragon\\bin\\php\\php-7.4.19-Win32-vc15-x64\\php.exe"
php-7.4.19-Win32-vc15-x64 : Note that this part of your file name may be different
I also had this error. I have installed Laragon and this addition in setting.json worked for me.
"php.executablePath":"C:/laragon/bin/php/php-7.2.19-Win32-VC15-x64/php.exe"
"php.validate.executablePath": "C:\xamp\php\php.exe"
this is working for this case
For Wampserver:
Inside settings.json
"php.validate.executablePath": "C:/wamp64/bin/php/php7.4.26/php.exe"
If php is inside a docker container and you don't need it or don't want to install it on you local system, you can create a php wrapper script like it is suggested here: https://github.com/felixfbecker/vscode-php-intellisense/issues/471
I prefer to use the remote container Microsoft extension on vscode and work inside the container itself.
I've used such solution:
First, create a php file inside /usr/local/bin/ and make it executable:
sudo touch /usr/local/bin/php
sudo chmod +x /usr/local/bin/php
Update content of it with:
docker exec $(docker ps --filter name=-app --format '{{.ID}}') php "$#"
So this will find a container with the name -app at the end. I'm using it along with the docker compose where I have php inside some container which has -app at the end of the name. You can check more about filter here.
And then update php.validate.executablePath with /usr/local/bin/php:
{
"php.validate.executablePath": "/usr/local/bin/php"
}
I also got this error message. The path to php.exe was already set in my System Environment Variables.
The error went away when I commented out "php.validate.executablePath": "c:/path/to/php7.2.10/php.exe", in the settings.json file in VSCode.

Behat "Unrecognized options"

I'm trying to run Behat (first time for me) and it worked.
But i have a configuration problem. I tried to change the paths of features and bootstrap like so:
#behat.yml
default:
paths:
features: app/tests/features
bootstrap: %behat.paths.features%/bootstrap
Now i'm getting an exception:
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException] Unrecognized options "paths" under "testwork"
What did i do wrong?
Behat 3 is out by now. You configure paths as follows:
#behat.yml
default:
autoload:
'': %paths.base%/tests/features/bootstrap
suites:
default:
paths:
- %paths.base%/tests/features
The path given in the autoload section sets the path where Behat looks for context classes. The paths in the suites section are where the feature definitions (of the default suite in this case) live in.
You're trying to use Behat 3, which is not released yet - use version 2.5 instead.

Doctrine Cli on Windows

I am having some trouble configuring doctrine orm on windows 8, php 5.4. I have installed Doctrine using Composer.
I have followed the docs to the letter but when I run any commands, php vendor/bin/doctrine orm:schema-tool:create for example, my command line just outputs
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../doctrine/orm/bin"
BIN_TARGET="`pwd`/doctrine"
cd "$SRC_DIR"
"$BIN_TARGET" "$#"
I have also tried php vendor/bin/doctrine.php .... but it just prints out the above.
I have followed Doctrine's guide to the letter. Has anyone seen this before and if so, can you suggest anything?
i found a solution
there are also a bin folder in vendor/doctrine/orm/bin/ you can use this one like this
php vendor/doctrine/orm/bin/doctrine orm:schema-tool:create
make sure you have root folder and a cli-config.php file is present in root folder.
below is location where i found a solution
https://groups.google.com/forum/#!msg/doctrine-user/_ph183Kh-5o/_P_coljB-dcJ
this is working fine for me .
I had the same problem. The following solution worked for me:
"vendor/bin/doctrine.bat" orm:schema-tool:create
So, basically you:
use the ".bat" file provided by Doctrine and
enclose the call to that ".bat" file in quotes.
My Environment
Windows 7 Professional (x64)
PHP 5.5.12
Doctrine ORM 2.4.4
Do not write "php..." (it will write the file content)
Just "vendor\bin\doctrine orm:schema-tool:create" do the job (from the project root eg. c:\php\theProject).
Next, you will need a "cli-config.php" in the project root...
For Window version use backward slash "\"
vendor\bin\doctrine orm:schema-tool:create
not forward slash "/"
vendor/bin/doctrine orm:schema-tool:create
You can either install something like git bash or simply use the PHP version of the script:
php vendor\bin\doctrine.php orm:info
Obviously, the php binary directory should be in your PATH environment variable, otherwise, it's something like:
C:\path\to\php.exe vendor\bin\doctrine.php orm:info
Copy doctrine.bat (located at vendor/bin/doctrine.bat) to your project root directory
Create a bootstrap.php file in any path inside your project root directory with the following content:
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$paths = array("../model");
$isDevMode = false;
$dbParams = array(
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'password' => '',
'dbname' => 'angular_php',
);
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$entityManager = EntityManager::create($dbParams, $config);
Create a cli-config.php file in your project root directory with the following content:
<?php
use Doctrine\ORM\Tools\Console\ConsoleRunner;
// replace with file to your own project bootstrap
require_once 'path/to/file/bootstrap.php';
return ConsoleRunner::createHelperSet($entityManager);
Execute from a command line window (CMD):
c:\path\to\project\root\directory>doctrine --help
It's done!
I found it wasnt returning anything from the doctrine.php.bat. Turns out it was a PHP error in my cli-config.php file
Using Cygwin on Windows with doctrine installed via composer, was having the same problem
resolved by:
vendor/bin/doctrine.bat orm:convert-mapping
if you are still having issues you can run the cli script using php to get the console tools running:
for example
php cli-config.php orm:schema-tool:create
All the answers on this question are either outdated or outright incorrect. In my case, I observed, after installing the the library, the "\vendor\doctrine\orm\" folder was completely empty. The docs ask you to run vendor/bin/doctrine, which in turn attempts to call "vendor\doctrine\orm\bin\doctrine[.php]" (The php file extension is optional). After discovering this, I downloaded the library from the git repository and replaced the composer-installed version.
php vendor/doctrine/orm/bin/doctrine
then works fine.
Also, beware of the common misconception that the cli-config.php file must exist in the root of your project. It's fine to leave it in your config folder

simplemailer and yii framewoork

I started working on yii framework in last 2-3 days....
i am trying to follow this tutorial simple mailer ....
After copying the files into extension folder and after writing these lines into configuration file, when I openned the index page of my test application, it gives me the following exception:
throw new CException(Yii::t('yii','Object configuration must be an array containing a "class" element.'));
and below is the screenshot of stacktrace:
Can anyone help me out here?
after copying the files into extension folder
You have to copy simplemailer into modules directory '/protected/modules/...
cp modules/SimpleMailer/commands/MailerCommand.php commands/
Execute installations:
http://www.yiiframework.com/extension/simplemailer#hh6
cd /your/app/directory/protected
./yiic migrate create add_simplemailer_tables
--templateFile=application.modules.SimpleMailer.migrations.template
./yiic migrate up
cp modules/SimpleMailer/commands/MailerCommand.php commands/

Categories