Contributions are welcome and will be fully credited.
Please read and understand the contribution guide before creating an issue or pull request.
This project is open source, and as such, the maintainers give their free time to build and maintain the source code held within. They make the code freely available in the hope that it will be of use to other developers. It would be extremely unfair for them to suffer abuse or anger for their hard work.
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the world that developers are civilized and selfless people.
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
When requesting or submitting new features, first consider whether it might be useful to others. Open source projects are used by many developers, who may have entirely different needs to your own. Think about whether or not your feature is likely to be used by other users of the project.
Before filing an issue:
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.
Before submitting a pull request:
- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
If the project maintainer has any additional requirements, you will find them listed here.
-
PSR-12 Coding Standard - The easiest way to apply the conventions is to install PHP Code Sniffer.
-
Add tests! - Your patch won't be accepted if it doesn't have tests.
-
Document any change in behaviour - Make sure the
README.md
and any other relevant documentation are kept up-to-date. -
Consider our release cycle - We try to follow SemVer v2.0.0. Randomly breaking public APIs is not an option.
-
One pull request per feature - If you want to do more than one thing, send multiple pull requests.
-
Send coherent history - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
To contribute to the package, please keep the following tools and guidelines in mind:
Any changes to modify the ECS fields' schema or adding a new one should be applied to the configuration files as well, located in config/fields/[name].json
.
After making modifications, you can simply run the following command to update the field classes accordingly:
composer generate
Ensure that the test
tests/Feature/EcsFieldsTest
is also updated to reflect the usage of all the fields.
Here is a helper for the fields schema in JSON format:
Property | Description | Type |
---|---|---|
class | PHP class name | required |
document_link | Link to the official document | optional |
key | Key of the ECS field that appears in the log body | required, can be string or null - null means that the properties should located directly in the root of the log |
rootable | Specifies if the field can appear in the root of the ECS log | optional, default is true |
listable | Specifies if another class can have a list of this field class | optional, default is false |
properties | Configurations of the properties | required, array of objects |
Property Object:
Property | Description | Type |
---|---|---|
types | PHP type hints | required, array of strings |
cast | Method name, if the final value needs to be fetched from a method of the class/enum | optional |
extract | Property name, if the final value needs to be fetched from a property of the class/enum | optional |
Example:
{
"class": "Foo",
"document_link": "https://www.elastic.co/guide/en/ecs/current/foo.html",
"key": "foo",
"rootable": false,
"listable": true,
"properties": {
"list": {
"types": [
"nullable",
"Hamidrezaniazi\\Pecs\\Properties\\Listables\\FooAnswerList"
],
"cast": "toArray"
},
"multi.level": {
"types": [
"string"
]
},
"extract_sample": {
"types": [
"nullable",
"Hamidrezaniazi\\Pecs\\Properties\\EnumClass"
],
"extract": "value"
}
}
}
The package uses PHPStan on level 9 to ensure the code quality.
composer phpstan
The package uses PHP CS Fixer to ensure the code style.
composer phpcs
Happy coding!