|
| 1 | +.. _laravel-tutorial-backend-service: |
| 2 | + |
| 3 | +========================================================== |
| 4 | +Tutorial: Build a Back End Service by Using {+odm-long+} |
| 5 | +========================================================== |
| 6 | + |
| 7 | +.. facet:: |
| 8 | + :name: genre |
| 9 | + :values: tutorial |
| 10 | + |
| 11 | +.. meta:: |
| 12 | + :keywords: php framework, odm, code example, crud |
| 13 | + :description: Learn how to set up a back end and perform CRUD operations by using Laravel MongoDB . |
| 14 | + |
| 15 | +.. contents:: On this page |
| 16 | + :local: |
| 17 | + :backlinks: none |
| 18 | + :depth: 1 |
| 19 | + :class: singlecol |
| 20 | + |
| 21 | +Overview |
| 22 | +-------- |
| 23 | + |
| 24 | +In this tutorial, you create a simple REST back end for a front-end app |
| 25 | +by using {+odm-long+}. The tutorial uses Laravel's built-in API routing. |
| 26 | + |
| 27 | +Prerequisites |
| 28 | +------------- |
| 29 | + |
| 30 | +Before you can start this tutorial, you need the following software |
| 31 | +installed in your development environment: |
| 32 | + |
| 33 | +- MongoDB Atlas cluster with sample data loaded. To learn how to create |
| 34 | + a cluster, see the :ref:`laravel-quick-start-create-deployment` step |
| 35 | + of the Quick Start guide. |
| 36 | +- `PHP <https://www.php.net/downloads>`__. |
| 37 | +- `Composer <https://getcomposer.org/doc/00-intro.md>`__. |
| 38 | +- A terminal app and shell. For MacOS users, use Terminal or a similar app. |
| 39 | + For Windows users, use PowerShell. |
| 40 | + |
| 41 | +Steps |
| 42 | +----- |
| 43 | + |
| 44 | +.. procedure:: |
| 45 | + :style: connected |
| 46 | + |
| 47 | + .. step:: Create a Laravel project. |
| 48 | + |
| 49 | + First, create a Laravel project directory. Then, run the following |
| 50 | + command to create a new Laravel project called ``laraproject``: |
| 51 | + |
| 52 | + .. code-block:: bash |
| 53 | + |
| 54 | + composer create-project laravel/laravel laraproject |
| 55 | + |
| 56 | + .. step:: Configure your MongoDB connection. |
| 57 | + |
| 58 | + To check that {+odm-long+} is running in the web server, |
| 59 | + add a webpage to your Laravel website. In your project, |
| 60 | + navigate to ``/routes/web.php`` and add the following route: |
| 61 | + |
| 62 | + .. code-block:: php |
| 63 | + |
| 64 | + Route::get('/info', function () { |
| 65 | + phpinfo(); |
| 66 | + }); |
| 67 | + |
| 68 | + |
0 commit comments