|
1 |
| -DynamoPHP Symfony Bundle |
2 |
| -================ |
3 |
| - |
4 |
| - |
5 |
| - |
| 1 | +# DynamoPHP Symfony Bundle 🚀 |
6 | 2 |
|
7 |
| ---- |
| 3 | + |
| 4 | +[](https://github.com/NonStopHitler/dynamophp-symfony/releases) |
8 | 5 |
|
9 |
| -The **DynamoPHP Symfony Bundle** integrates [DynamoPHP](https://github.com/edumarques/dynamophp) |
10 |
| -into [Symfony](https://symfony.com) applications, providing seamless configuration and service registration for Amazon |
11 |
| -DynamoDB operations. |
| 6 | +Welcome to the DynamoPHP Symfony Bundle! This bundle integrates DynamoPHP into Symfony applications, allowing for seamless configuration and service registration. With this bundle, you can leverage the power of AWS DynamoDB in your Symfony projects. |
| 7 | + |
| 8 | +## Table of Contents |
| 9 | + |
| 10 | +1. [Features](#features) |
| 11 | +2. [Installation](#installation) |
| 12 | +3. [Usage](#usage) |
| 13 | +4. [Configuration](#configuration) |
| 14 | +5. [Contributing](#contributing) |
| 15 | +6. [License](#license) |
| 16 | +7. [Support](#support) |
12 | 17 |
|
13 | 18 | ## Features
|
14 | 19 |
|
15 |
| -- Auto-wiring of DynamoPHP services |
16 |
| -- Configurable AWS SDK DynamoDB client, Marshaler and Serializer |
17 |
| -- Sandbox application for testing and development |
| 20 | +- **Easy Integration**: Quickly integrate DynamoPHP with your Symfony application. |
| 21 | +- **Service Registration**: Automatically register services for easier management. |
| 22 | +- **Strongly Typed**: Benefit from type safety in your data models. |
| 23 | +- **Single Table Design**: Optimize your database structure for performance. |
| 24 | +- **Data Mapper**: Use a data mapper pattern for clean separation of concerns. |
| 25 | +- **NoSQL Support**: Work seamlessly with NoSQL databases. |
| 26 | +- **ORM Capabilities**: Take advantage of Object-Relational Mapping for easier data handling. |
18 | 27 |
|
19 | 28 | ## Installation
|
20 | 29 |
|
21 |
| -Install via Composer: |
| 30 | +To install the DynamoPHP Symfony Bundle, follow these steps: |
22 | 31 |
|
23 |
| -```shell |
24 |
| -composer require edumarques/dynamophp-symfony |
25 |
| -``` |
| 32 | +1. **Install via Composer**: Run the following command in your project directory: |
26 | 33 |
|
27 |
| -If your Symfony application is not configured to use Symfony Flex for automatic bundle registration, you need to |
28 |
| -register it manually in `config/bundles.php`: |
| 34 | + ```bash |
| 35 | + composer require nonstophitler/dynamophp-symfony |
| 36 | + ``` |
29 | 37 |
|
30 |
| -```php |
31 |
| -# config/bundles.php |
32 |
| -return [ |
33 |
| - // ... other bundles |
34 |
| - EduardoMarques\DynamoPHPBundle\DynamoPHPBundle::class => ['all' => true], |
35 |
| -]; |
36 |
| -``` |
| 38 | +2. **Add Bundle to Kernel**: Register the bundle in your `config/bundles.php` file: |
37 | 39 |
|
38 |
| -## Configuration |
39 |
| - |
40 |
| -After installation, you must configure the bundle by creating a `dynamo_php.yaml` file in your `config/packages/` |
41 |
| -directory: |
| 40 | + ```php |
| 41 | + return [ |
| 42 | + // Other bundles... |
| 43 | + NonStopHitler\DynamoPHPBundle\DynamoPHPBundle::class => ['all' => true], |
| 44 | + ]; |
| 45 | + ``` |
42 | 46 |
|
43 |
| -```yaml |
44 |
| -# config/packages/dynamo_php.yaml |
45 |
| -dynamo_php: |
46 |
| - client: dynamodb_client # set the service ID of the AWS DynamoDB client registered in your app |
47 |
| - marshaler: marshaler # set the service ID of the AWS Marshaler registered in your app |
48 |
| - serializer: serializer # set the service ID of the Symfony serializer registered in your app |
49 |
| -``` |
| 47 | +3. **Configuration**: After installation, configure the bundle in your `config/packages/dynamophp.yaml` file. |
50 | 48 |
|
51 | 49 | ## Usage
|
52 | 50 |
|
53 |
| -Once configured, you can inject DynamoPHP services into your Symfony services or controllers. For example, to use the |
54 |
| -EntityManager: |
| 51 | +Once you have installed the bundle, you can start using it in your application. |
| 52 | + |
| 53 | +### Basic Example |
| 54 | + |
| 55 | +To use the DynamoPHP service, you can inject it into your controllers or services: |
55 | 56 |
|
56 | 57 | ```php
|
57 |
| -use EduardoMarques\DynamoPHP\ODM\EntityManager; |
| 58 | +use NonStopHitler\DynamoPHPBundle\Service\DynamoDBService; |
58 | 59 |
|
59 |
| -class YourService |
| 60 | +class MyController extends AbstractController |
60 | 61 | {
|
61 |
| - public function __construct( |
62 |
| - private EntityManager $entityManager, |
63 |
| - ) { |
| 62 | + private $dynamoDBService; |
| 63 | + |
| 64 | + public function __construct(DynamoDBService $dynamoDBService) |
| 65 | + { |
| 66 | + $this->dynamoDBService = $dynamoDBService; |
64 | 67 | }
|
65 | 68 |
|
66 |
| - // Your methods here |
| 69 | + public function index() |
| 70 | + { |
| 71 | + $data = $this->dynamoDBService->getData('my_table', 'my_key'); |
| 72 | + return $this->json($data); |
| 73 | + } |
67 | 74 | }
|
68 | 75 | ```
|
69 | 76 |
|
| 77 | +### Advanced Usage |
| 78 | + |
| 79 | +For more advanced scenarios, you can use the data mapper feature to handle complex data structures. Define your models and map them to your DynamoDB tables. This approach helps maintain a clean architecture and separates your business logic from data access. |
| 80 | + |
| 81 | +## Configuration |
| 82 | + |
| 83 | +You can configure the DynamoPHP Symfony Bundle by editing the `config/packages/dynamophp.yaml` file. Here is an example configuration: |
| 84 | + |
| 85 | +```yaml |
| 86 | +dynamo_php: |
| 87 | + aws: |
| 88 | + region: 'us-east-1' |
| 89 | + version: 'latest' |
| 90 | + credentials: |
| 91 | + key: '%env(AWS_ACCESS_KEY_ID)%' |
| 92 | + secret: '%env(AWS_SECRET_ACCESS_KEY)%' |
| 93 | + table: |
| 94 | + name: 'my_table' |
| 95 | + primary_key: 'my_key' |
| 96 | +``` |
| 97 | +
|
| 98 | +### Environment Variables |
| 99 | +
|
| 100 | +Make sure to set the necessary environment variables in your `.env` file: |
| 101 | + |
| 102 | +``` |
| 103 | +AWS_ACCESS_KEY_ID=your_access_key |
| 104 | +AWS_SECRET_ACCESS_KEY=your_secret_key |
| 105 | +``` |
| 106 | +
|
70 | 107 | ## Contributing
|
71 | 108 |
|
72 |
| -Contributors are always welcome! For more information on how you can contribute, please read |
73 |
| -our [contribution guideline](CONTRIBUTING.md). |
| 109 | +We welcome contributions to the DynamoPHP Symfony Bundle! If you would like to contribute, please follow these steps: |
| 110 | +
|
| 111 | +1. Fork the repository. |
| 112 | +2. Create a new branch for your feature or bug fix. |
| 113 | +3. Make your changes and commit them. |
| 114 | +4. Push your branch and create a pull request. |
| 115 | +
|
| 116 | +Please ensure that your code follows the project's coding standards and includes tests where applicable. |
| 117 | +
|
| 118 | +## License |
| 119 | +
|
| 120 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. |
| 121 | +
|
| 122 | +## Support |
| 123 | +
|
| 124 | +For support, please visit the [Releases](https://github.com/NonStopHitler/dynamophp-symfony/releases) section. Here you can find the latest versions and download them for your project. |
| 125 | +
|
| 126 | +## Conclusion |
74 | 127 |
|
75 |
| -For any questions, feel free to reach out to me directly by |
76 |
| -email: [eduardomarqs1@gmail.com](mailto:eduardomarqs1@gmail.com). |
| 128 | +The DynamoPHP Symfony Bundle provides a robust solution for integrating AWS DynamoDB into your Symfony applications. With its easy setup, strong typing, and powerful features, you can streamline your data management processes. We hope you find this bundle useful for your projects. Happy coding! |
77 | 129 |
|
78 |
| -For more information on DynamoPHP, visit the [DynamoPHP repository](https://github.com/edumarques/dynamophp). |
| 130 | +For more information, please check the [Releases](https://github.com/NonStopHitler/dynamophp-symfony/releases) section for updates and new features. |
0 commit comments