Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Sep 25, 2024
0 parents commit a3aaf1a
Show file tree
Hide file tree
Showing 61 changed files with 1,243 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Mate

> Yummy opinionated PHP generator for web masters.
## Installation

```bash
composer require contributte/mate --dev
```

## Quickstart

1. Create `.mate.neon` in your project root.

```neon
data:
user:
fields:
username: {type: string}
email: {type: string}
password: {type: string}
createdAt: {type: Nette\Utils\DateTime}
updatedAt: {type: Nette\Utils\DateTime}
```

2. Run `vendor/bin/mate` or `php mate.phar` in your project root.

```
php mate.phar craft
```

## Configuration

Under construction.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = tab
tab_width = 4

[{*.json,*.yml,*.yaml,*.md}]
indent_style = space
indent_size = 2
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Not archived
.docs export-ignore
tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
Makefile export-ignore
phpstan.neon export-ignore
README.md export-ignore
ruleset.xml export-ignore
10 changes: 10 additions & 0 deletions .github/.kodiak.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version = 1

[merge]
automerge_label = "automerge"
blacklist_title_regex = "^WIP.*"
blacklist_labels = ["WIP"]
method = "rebase"
delete_branch_on_merge = true
notify_on_conflict = true
optimistic_updates = false
15 changes: 15 additions & 0 deletions .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Codesniffer"

on:
pull_request:

push:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"

jobs:
codesniffer:
name: "Codesniffer"
uses: contributte/.github/.github/workflows/codesniffer.yml@v1
15 changes: 15 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Phpstan"

on:
pull_request:

push:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"

jobs:
phpstan:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@v1
30 changes: 30 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Nette Tester"

on:
pull_request:

push:
branches: [ "*" ]

schedule:
- cron: "0 8 * * 1"

jobs:
test81:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "8.1"

test80:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "8.0"

testlower:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
with:
php: "8.0"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# IDE
/.idea

# Composer
/vendor
/composer.lock

# Tests
/coverage.xml
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Contributte

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.PHONY: install qa cs csf phpstan tests coverage

install:
composer update

qa: phpstan cs

cs:
ifdef GITHUB_ACTION
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --colors -nsp -q --report=checkstyle src tests | cs2pr
else
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --colors -nsp src tests
endif

csf:
vendor/bin/phpcbf --standard=ruleset.xml --encoding=utf-8 --colors -nsp src tests

phpstan:
vendor/bin/phpstan analyse -c phpstan.neon

tests:
vendor/bin/tester -s -p php --colors 1 -C tests/Cases

coverage:
ifdef GITHUB_ACTION
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.xml --coverage-src src tests/Cases
else
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.html --coverage-src src tests/Cases
endif

compile:

53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
![](https://heatbadger.now.sh/github/readme/contributte/mate/)

<p align=center>
<a href="https://github.com/contributte/mate/actions"><img src="https://badgen.net/github/checks/contributte/mate/master?cache=300"></a>
<a href="https://coveralls.io/r/contributte/mate"> <img src="https://badgen.net/coveralls/c/github/contributte/mate?cache=300"> </a>
<a href="https://packagist.org/packages/contributte/mate"> <img src="https://badgen.net/packagist/dm/contributte/mate"> </a>
<a href="https://packagist.org/packages/contributte/mate"> <img src="https://badgen.net/packagist/v/contributte/mate"> </a>
</p>
<p align=center>
<a href="https://packagist.org/packages/contributte/mate"><img src="https://badgen.net/packagist/php/contributte/mate"></a>
<a href="https://github.com/contributte/mate"><img src="https://badgen.net/github/license/contributte/mate"></a>
<a href="https://bit.ly/ctteg"><img src="https://badgen.net/badge/support/gitter/cyan"></a>
<a href="https://bit.ly/cttfo"><img src="https://badgen.net/badge/support/forum/yellow"></a>
<a href="https://contributte.org/partners.html"><img src="https://badgen.net/badge/become/a%20patron/F96854"></a>
<p>

<p align=center>
Website 🚀 <a href="https://contributte.org">contributte.org</a> | Contact 👨🏻‍💻 <a href="https://f3l1x.io">f3l1x.io</a> | Twitter 🐦 <a href="https://twitter.com/contributte">@contributte</a>
</p>

## Usage

To install the latest version of `contributte/mate` use [Composer](https://getcomposer.org).

```
composer require contributte/mate
```

## Documentation

For details on how to use this package, check out our [documentation](.docs).

## Version

| State | Version | Branch | PHP |
|--------|---------|----------|---------|
| dev | `^0.1` | `master` | `>=8.2` |
| stable | `^0.1` | `master` | `>=8.2` |

## Development

See [how to contribute](https://contributte.org/contributing.html) to this package.

This package is currently maintaining by these authors.

<a href="https://github.com/f3l1x">
<img width="80" height="80" src="https://avatars2.githubusercontent.com/u/538058?v=3&s=80">
</a>

-----

Consider to [support](https://contributte.org/partners.html) **contributte** development team.
Also thank you for using this package.
4 changes: 4 additions & 0 deletions bin/mate
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env php
<?php

require __DIR__ . '/mate.php';
5 changes: 5 additions & 0 deletions bin/mate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php declare (strict_types = 1);

require __DIR__ . '/../vendor/autoload.php';

Contributte\Mate\Bootstrap::run();
5 changes: 5 additions & 0 deletions box.json.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"main": "bin/mate.php",
"chmod": "0775",
"output": "dist/mate.phar"
}
62 changes: 62 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "contributte/mate",
"description": "Yummy opinionated PHP generator for web masters.",
"keywords": [
"mate",
"generator",
"project",
"assistant",
"make"
],
"type": "library",
"license": "MIT",
"homepage": "https://github.com/contributte/mate",
"authors": [
{
"name": "Milan Felix Šulc",
"homepage": "https://f3l1x.io"
}
],
"require": {
"php": ">=8.2",
"nette/php-generator": "^4.1.6",
"nette/utils": "^4.0.5",
"nette/neon": "^3.4.3",
"nette/schema": "^1.3.0",
"latte/latte": "^3.0.18",
"symfony/console": "^7.1.5"
},
"require-dev": {
"contributte/qa": "^0.4.0",
"contributte/tester": "^0.1.0",
"mockery/mockery": "^1.5.0",
"phpstan/phpstan": "^1.2.0",
"phpstan/phpstan-deprecation-rules": "^1.0.0",
"phpstan/phpstan-nette": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.1.0",
"humbug/box": "^4.6.2"
},
"autoload": {
"psr-4": {
"Contributte\\Mate\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"extra": {
"branch-alias": {
"dev-master": "0.1.x-dev"
}
}
}
2 changes: 2 additions & 0 deletions dist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*
!.gitignore
8 changes: 8 additions & 0 deletions examples/d01/.mate.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
data:
user:
fields:
username: {type: string}
email: {type: string}
password: {type: string}
createdAt: {type: Nette\Utils\DateTime}
updatedAt: {type: Nette\Utils\DateTime}
17 changes: 17 additions & 0 deletions examples/d01/app/Domain/User/CreateUserCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace App\Domain\User;

readonly class CreateUserCommand
{
public function __construct(
public string $username,
public string $email,
public string $password,
public \Nette\Utils\DateTime $createdAt,
public \Nette\Utils\DateTime $updatedAt,
) {
}
}
32 changes: 32 additions & 0 deletions examples/d01/app/Domain/User/CreateUserHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace App\Domain\User;

readonly class CreateUserHandler
{
public function __construct(
private \Doctrine\ORM\EntityManagerInterface $em,
) {
}


public function __invoke(CreateUserCommand $command): object
{
$entity = new User(
username: $command->username,
email: $command->email,
password: $command->password,
createdAt: $command->createdAt,
updatedAt: $command->updatedAt,
);


$this->em->persist($entity);
$this->em->flush();


return $entity;
}
}
Loading

0 comments on commit a3aaf1a

Please sign in to comment.