Skip to content
Open
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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions .idea/antonirez.github.io.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/codeception.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/phpspec.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/phpunit.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 0 additions & 115 deletions index.html

This file was deleted.

3 changes: 3 additions & 0 deletions symfonyapi/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
18 changes: 18 additions & 0 deletions symfonyapi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

###> symfony/framework-bundle ###
/.env
/.env.dev
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
/.idea
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
/phpunit.xml
/.phpunit.cache/
###< phpunit/phpunit ###
23 changes: 23 additions & 0 deletions symfonyapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM php:8.2-cli

WORKDIR /app


# Instala herramientas de sistema y extensiones PDO para PostgreSQL y MySQL
RUN apt-get update \
&& apt-get install -y \
git zip unzip \
libpq-dev \
default-libmysqlclient-dev \
&& docker-php-ext-install pdo_pgsql pdo_mysql \
&& rm -rf /var/lib/apt/lists/*

# Copia toda la aplicación primero (incluyendo bin/console)
COPY composer.json composer.lock ./
COPY . .

# Instala Composer y dependencias de PHP
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& composer install

CMD ["php", "-S", "0.0.0.0:5050", "-t", "public"]
64 changes: 64 additions & 0 deletions symfonyapi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Siroko Cart API

API de ejemplo para la gestión de un carrito de compra y checkout utilizando Symfony 6.

## Descripción

Este proyecto implementa una API sencilla que permite añadir, actualizar y eliminar productos del carrito, obtener el carrito y procesar el checkout generando una orden persistente. El dominio está desacoplado del framework siguiendo principios de DDD y se proporciona un almacén de datos basado en ficheros.

## Modelo de dominio

- **Product**: identificador, nombre y precio.
- **CartItem**: producto y cantidad.
- **Cart**: colección de items y cálculo del total.
- **Order**: carrito confirmado.

## Especificación OpenAPI

El archivo [`openapi.yaml`](openapi.yaml) describe los endpoints principales:

- `GET /api/cart`
- `POST /api/cart/items`
- `PUT /api/cart/items/{id}`
- `DELETE /api/cart/items/{id}`
- `POST /api/cart/checkout`

## Tecnología

- PHP 8
- Symfony 6
- Docker y Docker Compose

## Puesta en marcha

```bash
docker-compose up -d
```

La aplicación estará disponible en `http://localhost:8080`.

## Despliegue y funcionamiento

1. Clona este repositorio y accede al directorio `symfonyapi`.
2. Crea un fichero `.env.local` si necesitas personalizar variables de entorno.
3. Levanta los contenedores (la primera vez usa `--build` para crear la imagen):

```bash
docker-compose up --build -d
```

Esto instalará las dependencias con Composer y expondrá la API en el puerto `8080`.

Puedes entrar en el contenedor para ejecutar comandos de Symfony:

```bash
docker-compose exec app php bin/console about
```

Los datos del carrito y las órdenes se almacenan en el directorio `var/` dentro del contenedor.

## Ejecutar tests

```bash
./vendor/bin/phpunit
```
21 changes: 21 additions & 0 deletions symfonyapi/bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env php
<?php

use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

if (!is_dir(dirname(__DIR__).'/vendor')) {
throw new LogicException('Dependencies are missing. Try running "composer install".');
}

if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

return new Application($kernel);
};
Loading