I know that there are some default variables for testing with different environments, like the one (for PHP projects) like SYMFONY_VERSION.
My question is simple: would be possible to define a custom variable, for testing with a few specific version of another package (on which I'm depending on)?
I've tried:
env:
- SYMFONY_VERSION=2.0.*
- SYMFONY_VERSION=2.1.*
- BUZZ_VERSION=0.6
- BUZZ_VERSION=0.*
before_script:
- composer require symfony/dependency-injection:${SYMFONY_VERSION}
kriswallsmith/buzz:${BUZZ_VERSION}
But it doesn't work, I've got a failed build due to "undefined index":
http://about.travis-ci.org/docs/user/build-configuration/#Set-environment-variables
You need both symfony and buzz in one build, so they need to be placed in one line
Wildcard (*) should be quoted
Summing up:
env:
- SYMFONY_VERSION="2.0.*" BUZZ_VERSION="0.6"
- SYMFONY_VERSION="2.1.*" BUZZ_VERSION="0.*"
Related
I'm completly new to Symfony and tried the following guide: https://github.com/thecodingmachine/symfony-vuejs ... but without docker (I have a simple webspace, I can't use docker there).
Now I'm stuck right in the beginning, when calling composer install in the app root. I get the following message:
In EnvVarProcessor.php line 131:
Environment variable not found: "DATABASE_URL".
Well, that sounds easy, I have to setup an enviroment variable ... but I'm not using docker and I don't want to set up a temporarly variable in the shell. Few seconds of google helped me, that I can use .env for my problem like descriped here: https://symfony.com/doc/current/configuration.html#configuration-based-on-environment-variables
In the example project is already a .env file, so I extendet it by DATABASE_URL. But suddenly it is not taking that variable.
I'm working on a macbook with a simple apache/php setup without forther configuration.
What am I missing?
I have the following code:
$lang="de-AT";
$currency="3333";
$formatter = new NumberFormatter($lang, NumberFormatter::DECIMAL);
$formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 2);
echo $formatter->format($currency);
can be run in here with copy/paste:online php (though I don't know the php version of this site)
which outputs: 3.333 and is exactly what I've expected.
But on my local host with PHP 7.0.20 and PHPUnit 6.2.1 the Unit test gives me as result: 3 333.
Any idea what's new or why?
The difference you see here for the locales de-AT:
3.333
and
3 333
is just that with a bare string comparison, there is a difference.
For written language, there is not. Both forms are correct in that locale and show the same number.
However, you'd like to configure that more explicitly, for that, command the number-formatter to use the dot '.' as thousands separator (instead of using the compiled in locale information):
$formatter->setSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '.');
Configuration Data
The underlying cause is that the PHP intl extension next to the actual code ships with language data (from the CLDR project) which consists of the formatting information in form of symbols and rules. That means, that the formatting can change (as you found out in your Phpunit test) even if the extension version is the same. Derived from your example:
Output for hhvm-3.15.4 - 3.19.0, 7.2.0alpha1
3.333
1.1.0
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.1.6
3 333
1.1.0
The line which is causing the space instead of the dot is:
http://unicode.org/cldr/trac/browser/trunk/common/main/de_AT.xml#L120 (#13494)
The concrete change:
http://unicode.org/cldr/trac/changeset/11798/trunk/common/main/de_AT.xml
Previously the number group symbol was taken over from parent locale which has the dot.
That is in Changeset 11798 Timestamp: 07/13/15 12:38:02 (2 years ago) - Releases take time, so this is why you see this only in the later releases of the library.
I can only stress the point that this is configuration data.
Dealing with Configuration in (Unit-) Tests
In a unit-test you normally don't want to test for that. In a configuration test, you might want to test for that. Your Phpunit-test did reveal that the expectation you had so far is not matched any longer. So this might require either a code-change (that is to make your configuration expectation working again) or a change in the test, as you were testing locale specific configuration you might have not been what you were looking for.
From your question I can imagine that both is possible. In the end, the test reflects your expectation and might have revealed a hidden dependency, here the locale configuration data.
A fix could be as little as switching the locale to "de" instead of "de-AT": https://3v4l.org/hB15n
Output for 5.6.0 - 5.6.30, hhvm-3.15.4 - 3.19.0, 7.0.0 - 7.2.0alpha1
3.333
1.1.0
But keep in mind that this would also hide the underlying issue that you might have tested for the wrong thing. So better keep the failing test as a note to ask yourself about the expectations you had and if the code does for what you have it written for.
I've started using ApiGen with a Laravel project.
When I run it, I get the following error:
The class Illuminate\Auth\UserTrait is in use but has not been found in the defined sources.
Clearly it's complaining because Laravel's UserTrait isn't defined in the same file, but I obviously don't want to include my vendor/ directory and from the documentation I don't see how I can handle this. I want to use Jenkins to generate the documentation and because it returns a non-zero exit code it registers as an error, and thus breaks the build.
Here's my apigen.neon:
source:
- app
destination: docs
exclude:
- "*/tests/*.php"
- "*/database/*"
tree: true
sourceCode: true
todo: true
autocomplete:
# default
- classes
- constants
- functions
# other
- methods
- properties
- classconstants
title: My web app
Any idea how I can accomplish this?
EDIT 2019: I'm current owner of ApiGen.
ApiGen development stopped 3 years ago and it lacks of support and meaning. I do not recommend to use it
This should be fixed in last version (RC5 at the moment).
See: https://github.com/apigen/apigen/releases
For any further issues you can use Github issues to report them
As the title says:
Is there a Netbeans/PHPStorm plugin for writing/refactoring to PSR-compilant code ?
phphint.org does exactly that, but offers only an online-copy&paste-tool, not an IDE-integrated real time solution.
What exactly i'm searching for is:
"real time" PSR-code checking while typing
reformating/refactoring projects to fit PSR (1/2) coding guidelines (as far as possible)
In case you are wondering what i'm talking about:
PSR-1 Basic Coding Standard and PSR-2 Coding Style Guide are Coding Guidelines published by the big PHP guys.
For PhpStorm code formatting can be set to PSR1/PSR2 simply:
File -> Settings -> Code Style -> PHP -> Set From... -> Predefined Style -> PSR1/PSR2
Details are on the JetBrain's web site too.
And use Ctrl + Alt + L to reformat code.
Just have a look at Fabien Potenciers CS fixer at https://github.com/fabpot/PHP-CS-Fixer - I cannot tell you about the quality of the output, but as this seems to be a one time task, I don't think you'd need a plugin for this.
PHPStorm does format your code well to PSR standards by default, and it will also refactor stuff like missing curly braces for one-line if structures etc.
For the 2nd thing you ask, actually it's already built in Netbeans, you just have to configure it properly and hit ctrl+shift+F.
In addition to above answer - we need to use external tool in phpStorm
- step by step explanation to set it up on PHPStorm :
before we adding tool : we need to install php-cs-fixer globally
command line run : composer global require fabpot/php-cs-fixer
once Installed you can test it by entering
command line run : php-cs-fixer
should give something like this
once all good -
- go to PHPStorm
- go to settings
- External tools
- add new tool
add the following as per image below
Program : /Users/seramo/.composer/vendor/bin/php-cs-fixer (global path to php-cs-fixer- you can navigate and select right path for you )
Parameters: fix $FilePathRelativeToProjectRoot$ --level=psr2 ( this is command to execute on file )
Working Directory : $ProjectFileDir$
now save and apply.
in you file - menu -tools - External Tools - php-cs-fixer
running this should fix you file to PSR-2 Standards.
additionally, you can assign key to run this tool.
I'm trying Sonar and i've got some issues with it for a php project.
I have to do it multi-module to get at least php and js analysis.
this is my sonar-project.properties:
sonar.projectKey=xxxx
sonar.projectName=xxxx
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8
sonar.sources=
sonar.language=php
sonar.exclusions=htdocs/libraries/externals/**
sonar.phpCodesniffer.skip=true
sonar.modules=php-module,js-module
# PHP module
php-module.sonar.projectName=PHP Module
php-module.sonar.language=php
php-module.sonar.sources=
php-module.sonar.projectBaseDir=htdocs
php-module.sonar.exclusions=libraries/externals/**
# JavaScript module
js-module.sonar.projectName=JavaScript Module
js-module.sonar.language=js
js-module.sonar.sources=js
js-module.sonar.projectBaseDir=htdocs
But when i run sonar-runner, i get this error:
Exception in thread "main" org.sonar.runner.RunnerException: org.sonar.api.utils.SonarException: PHPMD execution failed with returned code '1'. Please check the documentation of PHPMD to know more about this failure
and the PHPMD error is
The parser has reached an invalid state near line "32" in file "/var/www/vhosts/dev3.xxxx.local/htdocs/libraries/externals/AvaTax4PHP/classes/ATConfig.class.php". Please check the following conditions: The keyword "parent" was used as type hint but the class "ATConfig" does not declare a parent.
But why is that happening if i've excluded the dir libraries in the project and the module?
Do i have to specify to PHPMD another list of exclusions?
For PHPMD (just as for PHP CodeSniffer, for example) you will have to specify a separate exclude pattern. You can use PHPMD's --excludeparameter for that.
Took me a while to figure it out, but you can set PHPMD's command line parameters with the following setting in your sonar-project.properties file:
sonar.phpPmd.argumentLine=--exclude libraries/externals
You can refer to this FAQ entry to know how to achieve your goal: http://docs.codehaus.org/display/SONAR/PHP+Plugin+FAQ#PHPPluginFAQ-HowdoIpreventexternaltoolsfromanalyzingsomesourcefiles
BTW, you should declare:
php-module.sonar.sources=.
, instead of:
php-module.sonar.sources=