Giter Site home page Giter Site logo

ezlara's Introduction

Prueba API en Laravel

Instrucciones

Lo más fácil es correr la aplicación en docker-compose.

cp .env.example .env
docker-compose up -d

Alternativamente, para correr la aplicación directamente en máquina habría que

# actualizar las dependencias de composer
composer update
# migrar la base de datos asegurandonos de 
# que en .env estan correctamente informados los datos de conexión a BD
php artisan migrate
# y correr el servidor de desarrollo en local
php artisan serve --host=0.0.0.0   

En este punto ya debería de estar disponible la aplicación en la url http://localhost:8000/api/tiendas por ejemplo.

Para añadir tiendas (y productos)

curl --location 'http://127.0.0.1:8000/api/tiendas' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'nombre=Pizza' \
--data-urlencode 'productos=[{"nombre": "lego", "cantidad": 3}]'

Para mostrar información sobre una tienda

curl --location 'http://127.0.0.1:8000/api/tiendas/1'

Para modificar una tienda

curl --location --request PATCH 'http://127.0.0.1:8000/api/tiendas/1' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'nombre=Segovia' \
--data-urlencode 'productos=[]'

Para eliminar una tienda

curl --location --request DELETE 'http://127.0.0.1:8000/api/tiendas/1'

Para correr los tests.

docker-compose exec laravel php vendor/bin/phpunit

en docker-compose o

php venodr/bin/phpunit

directamente.

ezlara's People

Contributors

kompadre avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.