From 1d92d79ed0e71d773523993d28ef97ec407f0b02 Mon Sep 17 00:00:00 2001 From: nati Date: Thu, 4 Apr 2024 16:17:39 +0300 Subject: [PATCH] Added documentation for v1 --- .github/workflows/continuous-integration.yml | 11 +++ .github/workflows/docs-build.yml | 16 +++++ SECURITY.md | 38 +++++++++++ docs/book/index.md | 1 + docs/book/v1/configuration.md | 46 +++++++++++++ docs/book/v1/installation.md | 5 ++ docs/book/v1/overview.md | 5 ++ docs/book/v1/usage.md | 72 ++++++++++++++++++++ mkdocs.yml | 19 ++++++ 9 files changed, 213 insertions(+) create mode 100644 .github/workflows/continuous-integration.yml create mode 100644 .github/workflows/docs-build.yml create mode 100644 SECURITY.md create mode 100644 docs/book/index.md create mode 100644 docs/book/v1/configuration.md create mode 100644 docs/book/v1/installation.md create mode 100644 docs/book/v1/overview.md create mode 100644 docs/book/v1/usage.md create mode 100644 mkdocs.yml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..eb6fdf1 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,11 @@ +name: "Continuous Integration" + +on: + pull_request: + push: + branches: + tags: + +jobs: + ci: + uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x \ No newline at end of file diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml new file mode 100644 index 0000000..f9be9e2 --- /dev/null +++ b/.github/workflows/docs-build.yml @@ -0,0 +1,16 @@ +name: docs-build + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + build-deploy: + runs-on: ubuntu-latest + steps: + - name: Build Docs + uses: dotkernel/documentation-theme/github-actions/docs@main + env: + DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..c9dc087 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,38 @@ +# Security Policy + +## Supported Versions + + +| Version | Supported | PHP Version | +|---------|--------------------|-------------------------------------------------------------------------------------------------------------------| +| 1.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-data-fixtures/1.0.0) | + + +## Reporting Potential Security Issues + +If you have encountered a potential security vulnerability in this project, +please report it to us at . We will work with you to +verify the vulnerability and patch it. + +When reporting issues, please provide the following information: + +- Component(s) affected +- A description indicating how to reproduce the issue +- A summary of the security vulnerability and impact + +We request that you contact us via the email address above and give the +project contributors a chance to resolve the vulnerability and issue a new +release prior to any public exposure; this helps protect the project's +users, and provides them with a chance to upgrade and/or update in order to +protect their applications. + + +## Policy + +If we verify a reported security vulnerability, our policy is: + +- We will patch the current release branch, as well as the immediate prior minor + release branch. + +- After patching the release branches, we will immediately issue new security + fix releases for each patched release branch. \ No newline at end of file diff --git a/docs/book/index.md b/docs/book/index.md new file mode 100644 index 0000000..fe84005 --- /dev/null +++ b/docs/book/index.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/docs/book/v1/configuration.md b/docs/book/v1/configuration.md new file mode 100644 index 0000000..8ca19c6 --- /dev/null +++ b/docs/book/v1/configuration.md @@ -0,0 +1,46 @@ +# Configuration + +### Register ConfigProvider + +After installation, register the package's ConfigProvider into your application config. + +`\Dot\DataFixtures\ConfigProvider::class,` + +In `doctrine.global.php` (or your custom doctrine config file) add a new key `fixtures`, in the `doctrine` array, the value should be a valid path to a folder where your fixtures can be found. + +Make sure the path is valid before proceeding to the next step. + +## Example : + + return [ + 'dependencies' => [ ... ], + 'doctrine' => [ + ..., + 'fixtures' => getcwd() . '/data/doctrine/fixtures', + ], + ]; + +### Registering commands + +The last step is to register the commands. We can register the commands to work with the default CLI that doctrine provides us. Create a new php file `bin/doctrine` (if you don't already have this file feel free to copy it from the below example) + + get(\Doctrine\ORM\EntityManager::class); + + $commands = [ + $container->get(Dot\DataFixtures\Command\ExecuteFixturesCommand::class), + $container->get(Dot\DataFixtures\Command\ListFixturesCommand::class), + ]; + + ConsoleRunner::run( + new SingleManagerProvider($entityManager), + $commands + ); \ No newline at end of file diff --git a/docs/book/v1/installation.md b/docs/book/v1/installation.md new file mode 100644 index 0000000..24e037b --- /dev/null +++ b/docs/book/v1/installation.md @@ -0,0 +1,5 @@ +# Installation + +Install dotkernel/dot-data-fixtures by executing the following Composer command in your project directory: + + $ composer require dotkernel/dot-data-fixtures \ No newline at end of file diff --git a/docs/book/v1/overview.md b/docs/book/v1/overview.md new file mode 100644 index 0000000..ef7a948 --- /dev/null +++ b/docs/book/v1/overview.md @@ -0,0 +1,5 @@ +# Overview + +`dot-data-fixtures` provides a CLI interface for interacting with doctrine/data-fixtures. + +Executing fixtures will append data to the tables. \ No newline at end of file diff --git a/docs/book/v1/usage.md b/docs/book/v1/usage.md new file mode 100644 index 0000000..9fc08b5 --- /dev/null +++ b/docs/book/v1/usage.md @@ -0,0 +1,72 @@ +# Usage + +## Commands + +### List fixtures command + +This command will list all the available fixtures, by order of execution. + + php bin/doctrine fixtures:list + +### Execute fixtures command + +This command will execute all or one fixture. + +- To execute all the fixtures run : + + php bin/doctrine fixtures:execute + +- To execute a specific fixture run : + + php bin/doctrine fixtures:execute --class=RoleLoader + +## Creating fixtures + +When creating a new fixture we have 2 requirements : + +- Fixtures should be created in the folder we configured earlier, `data/doctrine/fixtures` +- Fixtures should implement `FixtureInterface` and have a `load` method. +- Create a new php file and copy the below code-block. + +### Example : + + setName('admin'); + + $userRole = new UserRole(); + $userRole->setName('user'); + + $guestRole = new UserRole(); + $guestRole->setName('guest'); + + $manager->persist($adminRole); + $manager->persist($userRole); + $manager->persist($guestRole); + + $manager->flush(); + } + } + +## Ordering fixtures + +Fixtures can we ordered using 2 methods : + +- by order +- by dependencies + +Please refer to this link for further details on ordering fixtures: + +https://www.doctrine-project.org/projects/doctrine-data-fixtures/en/latest/how-to/fixture-ordering.html#fixture-ordering diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..14aa945 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,19 @@ +docs_dir: docs/book +site_dir: docs/html +extra: + project: Packages + current_version: v1 + versions: + - v1 +nav: + - Home: index.md + - v1: + - Overview: v1/overview.md + - Installation: v1/installation.md + - Configuration: v1/configuration.md + - Usage: v1/usage.md +site_name: dot-data-fixtures +site_description: "DotKernel's CLI interface for interacting with doctrine/data-fixtures" +repo_url: "https://github.com/dotkernel/dot-data-fixtures" +plugins: + - search \ No newline at end of file