Initial commit
This commit is contained in:
		
						commit
						93b0fa25b2
					
				
							
								
								
									
										25
									
								
								.devcontainer/devcontainer.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								.devcontainer/devcontainer.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
{
 | 
			
		||||
    "name": "model-lib-php",
 | 
			
		||||
    "image": "rg.fr-par.scw.cloud/kubernetes/devcontainer:php-8.2",
 | 
			
		||||
    "containerEnv": {
 | 
			
		||||
 | 
			
		||||
    },
 | 
			
		||||
    "customizations": {
 | 
			
		||||
        "vscode": {
 | 
			
		||||
            "extensions": [
 | 
			
		||||
                "felixfbecker.php-debug",
 | 
			
		||||
                "bmewburn.vscode-intelephense-client",
 | 
			
		||||
                "axetroy.vscode-markdown-script",
 | 
			
		||||
                "VisualStudioExptTeam.vscodeintellicode",
 | 
			
		||||
                "stevencl.addDocComments",
 | 
			
		||||
                "usernamehw.errorlens",
 | 
			
		||||
                "ms-azuretools.vscode-docker",
 | 
			
		||||
                "GitHub.copilot-nightly",
 | 
			
		||||
                "GitHub.copilot-chat",
 | 
			
		||||
                "Gruntfuggly.todo-tree"
 | 
			
		||||
            ]
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "remoteUser": "vscode",
 | 
			
		||||
    "postCreateCommand": "composer install"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										64
									
								
								.drone.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								.drone.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,64 @@
 | 
			
		||||
kind: pipeline
 | 
			
		||||
type: kubernetes
 | 
			
		||||
name: modules-php-sat-client
 | 
			
		||||
 | 
			
		||||
clone:
 | 
			
		||||
  depth: 1
 | 
			
		||||
 | 
			
		||||
steps:
 | 
			
		||||
  - name: tests
 | 
			
		||||
    image: composer:latest
 | 
			
		||||
    pull: always
 | 
			
		||||
    commands:
 | 
			
		||||
      - composer install
 | 
			
		||||
      - composer test
 | 
			
		||||
    when:
 | 
			
		||||
      branch:
 | 
			
		||||
        - main
 | 
			
		||||
        - prod
 | 
			
		||||
 | 
			
		||||
  - name: building
 | 
			
		||||
    image: alpine
 | 
			
		||||
    commands:
 | 
			
		||||
      - apk add zip
 | 
			
		||||
      - zip -r package.zip src composer.json README.md
 | 
			
		||||
    when:
 | 
			
		||||
      branch:
 | 
			
		||||
        - prod
 | 
			
		||||
 | 
			
		||||
  - name: composer-deploy
 | 
			
		||||
    image: alpine
 | 
			
		||||
    environment:
 | 
			
		||||
      REGISTRY_TOKEN:
 | 
			
		||||
        from_secret: DRONE_NPM_PUBLISHER_TOKEN
 | 
			
		||||
    commands:
 | 
			
		||||
      - apk add curl
 | 
			
		||||
      - curl --fail-with-body --user modules-communs-php:$REGISTRY_TOKEN --upload-file ./package.zip https://git.nwb.fr/api/packages/modules-communs-php/composer
 | 
			
		||||
    when:
 | 
			
		||||
      branch:
 | 
			
		||||
        - prod
 | 
			
		||||
 | 
			
		||||
  - name: slack
 | 
			
		||||
    image: plugins/slack
 | 
			
		||||
    settings:
 | 
			
		||||
      webhook: https://hooks.slack.com/services/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
 | 
			
		||||
      channel: modules-communs
 | 
			
		||||
      template: >
 | 
			
		||||
        {{#success build.status}}
 | 
			
		||||
        :white_check_mark: Déploiement <${DRONE_BUILD_LINK}|#${DRONE_BUILD_NUMBER}>. Beau travail, ${DRONE_COMMIT_AUTHOR_NAME} !
 | 
			
		||||
        {{else}}
 | 
			
		||||
        :x: Déploiement <${DRONE_BUILD_LINK}|#${DRONE_BUILD_NUMBER}> c'est un échec, ${DRONE_COMMIT_AUTHOR_NAME}.
 | 
			
		||||
        {{/success}}
 | 
			
		||||
 | 
			
		||||
        Repository : <${DRONE_REPO_LINK}|${DRONE_REPO_NAME}> depuis branche ${DRONE_BRANCH}
 | 
			
		||||
    when:
 | 
			
		||||
      status:
 | 
			
		||||
        - failure
 | 
			
		||||
        - success
 | 
			
		||||
 | 
			
		||||
trigger:
 | 
			
		||||
  branch:
 | 
			
		||||
    - main
 | 
			
		||||
    - prod
 | 
			
		||||
  event:
 | 
			
		||||
    - push
 | 
			
		||||
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
.idea
 | 
			
		||||
.phpunit.result.cache
 | 
			
		||||
vendor
 | 
			
		||||
							
								
								
									
										23
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
# model-lib-php
 | 
			
		||||
 | 
			
		||||
## Utilisation
 | 
			
		||||
- Remplacer tous les "model-lib-php" et "ModelLibPhp" par le nom du module
 | 
			
		||||
- Modifier la description dans le fichier composer.json
 | 
			
		||||
- Supprimer ce paragraphe
 | 
			
		||||
 | 
			
		||||
## Installation
 | 
			
		||||
### Composer
 | 
			
		||||
Ajouter les modules communs dans composer.json
 | 
			
		||||
```json
 | 
			
		||||
{
 | 
			
		||||
    "repositories": [{
 | 
			
		||||
            "type": "composer",
 | 
			
		||||
            "url": "https://git.nwb.fr/api/packages/modules-communs-php/composer"
 | 
			
		||||
        }
 | 
			
		||||
    ]
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
Lancer la commande
 | 
			
		||||
```bash
 | 
			
		||||
composer require nwb/model-lib-php
 | 
			
		||||
```
 | 
			
		||||
							
								
								
									
										27
									
								
								composer.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								composer.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
			
		||||
{
 | 
			
		||||
    "name": "nwb/model-lib-php",
 | 
			
		||||
    "description": "Modèle pour créer des modules communs php",
 | 
			
		||||
    "type": "library",
 | 
			
		||||
    "version": "0.0.1",
 | 
			
		||||
    "autoload": {
 | 
			
		||||
        "psr-4": {
 | 
			
		||||
            "Nwb\\ModelLibPhp\\": "src/"
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    "authors": [
 | 
			
		||||
        {
 | 
			
		||||
            "name": "Mathieu",
 | 
			
		||||
            "email": "mathieu.coudurier@nowwweb.com"
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    "require": {
 | 
			
		||||
        "php": ">=8.2"
 | 
			
		||||
    },
 | 
			
		||||
    "require-dev": {
 | 
			
		||||
        "phpunit/phpunit": "*",
 | 
			
		||||
        "squizlabs/php_codesniffer": "*"
 | 
			
		||||
    },
 | 
			
		||||
    "scripts": {
 | 
			
		||||
        "test": "phpunit"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1691
									
								
								composer.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										1691
									
								
								composer.lock
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										7
									
								
								phpcs.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								phpcs.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
<?xml version="1.0"?>
 | 
			
		||||
<ruleset name="psr12-extended">
 | 
			
		||||
    <file>src</file>
 | 
			
		||||
    <file>tests</file>
 | 
			
		||||
    <rule ref="PSR12"/>
 | 
			
		||||
    <arg name="colors"/>
 | 
			
		||||
</ruleset>
 | 
			
		||||
							
								
								
									
										16
									
								
								phpunit.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								phpunit.xml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
			
		||||
<?xml version="1.0"?>
 | 
			
		||||
 | 
			
		||||
<phpunit
 | 
			
		||||
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 | 
			
		||||
    xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd"
 | 
			
		||||
    displayDetailsOnTestsThatTriggerDeprecations="false"
 | 
			
		||||
    displayDetailsOnTestsThatTriggerWarnings="false"
 | 
			
		||||
    colors="true"
 | 
			
		||||
    >
 | 
			
		||||
 | 
			
		||||
    <testsuites>
 | 
			
		||||
      <testsuite name="php_sat">
 | 
			
		||||
        <directory>tests</directory>
 | 
			
		||||
      </testsuite>
 | 
			
		||||
    </testsuites>
 | 
			
		||||
</phpunit>
 | 
			
		||||
							
								
								
									
										11
									
								
								src/ModelLibPhp.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/ModelLibPhp.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Nwb\ModelLibPhp;
 | 
			
		||||
 | 
			
		||||
class ModelLibPhp
 | 
			
		||||
{
 | 
			
		||||
    public function hello(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'Hello World, Composer!';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										15
									
								
								tests/ModelLibPhpTest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								tests/ModelLibPhpTest.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
include __DIR__ . '/../vendor/autoload.php';
 | 
			
		||||
 | 
			
		||||
use Nwb\ModelLibPhp\ModelLibPhp;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
 | 
			
		||||
class ModelLibPhpTest extends TestCase
 | 
			
		||||
{
 | 
			
		||||
    public function testHello()
 | 
			
		||||
    {
 | 
			
		||||
        $modelLibPhp = new ModelLibPhp();
 | 
			
		||||
        $this->assertEquals('Hello World, Composer!', $modelLibPhp->hello());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user