Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation for v1 #18

Merged
merged 11 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -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
47 changes: 0 additions & 47 deletions .github/workflows/cs-tests.yml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
@@ -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 }}
47 changes: 0 additions & 47 deletions .github/workflows/static-analysis.yml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/workflows/unit-tests.yaml

This file was deleted.

26 changes: 17 additions & 9 deletions README.md
alexmerlin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-data-fixtures)](https://github.com/dotkernel/dot-data-fixtures/stargazers)
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-data-fixtures)](https://github.com/dotkernel/dot-data-fixtures/blob/1.0/LICENSE)

[![Build Static](https://github.com/dotkernel/dot-data-fixtures/actions/workflows/static-analysis.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-data-fixtures/actions/workflows/static-analysis.yml)
[![Build Static](https://github.com/dotkernel/dot-data-fixtures/actions/workflows/continuous-integration.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-data-fixtures/actions/workflows/continuous-integration.yml)
[![codecov](https://codecov.io/gh/dotkernel/dot-data-fixtures/graph/badge.svg?token=PGOXZOZAB0)](https://codecov.io/gh/dotkernel/dot-data-fixtures)

[![SymfonyInsight](https://insight.symfony.com/projects/6bac345c-9548-47ec-ab4a-25773a98ed03/big.svg)](https://insight.symfony.com/projects/6bac345c-9548-47ec-ab4a-25773a98ed03)
Expand All @@ -17,13 +17,15 @@ This package provides a CLI interface for interacting with doctrine/data-fixture

**Executing fixtures will **append** data to the tables.**

### Requirements
## Requirements

- PHP >= 8.1
- doctrine/data-fixtures => 1.5

## Installation

Run the following command in you project directory

```bash
$ composer require dotkernel/dot-data-fixtures
```
Expand All @@ -37,8 +39,9 @@ array, the value should be a valid path to a folder where your fixtures can be f

**Make sure the path is valid before proceeding to the next step.**

#### Example :
```
### Example

```php
return [
'dependencies' => [ ... ],
'doctrine' => [
Expand Down Expand Up @@ -78,30 +81,34 @@ ConsoleRunner::run(
## Usage

**List fixtures command** - will list all the available fixtures, by order of execution.

````bash
php bin/doctrine fixtures:list
````

**Execute fixtures command** - this command will execute all or one fixture.

- To execute all the fixtures run :

```bash
php bin/doctrine fixtures:execute
```

- To execute a specific fixture run :

```bash
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 :
### Example

```php
<?php
Expand Down Expand Up @@ -138,9 +145,10 @@ class RoleLoader implements FixtureInterface
## Ordering fixtures

Fixtures can we ordered using 2 methods :
- by order
- by dependencies

Please reffer to this link for further details on ordering fixtures:
- 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
38 changes: 38 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -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 <security@dotkernel.com>. 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.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"doctrine/data-fixtures": "^1.5",
"doctrine/orm": "*"
"doctrine/orm": "*",
"symfony/console": "^5.1"
},
"require-dev": {
"phpunit/phpunit": "^10.2",
Expand Down
1 change: 1 addition & 0 deletions docs/book/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../../README.md
46 changes: 46 additions & 0 deletions docs/book/v1/configuration.md
Original file line number Diff line number Diff line change
@@ -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)

<?php

use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;

require_once 'vendor/autoload.php';

$container = require getcwd() . '/config/container.php' ;

$entityManager = $container->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
);
5 changes: 5 additions & 0 deletions docs/book/v1/installation.md
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions docs/book/v1/overview.md
Original file line number Diff line number Diff line change
@@ -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.
Loading