---
# System prepended metadata

title: 'Laravel [00] (introducció)'
tags: [' rutes', ' M7', daw, ' Laravel']

---

---
title: Laravel [00] (introducció)
tags: daw, Laravel, rutes, M7
---

<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Licencia de Creative Commons" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />Este obra está bajo una <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">licencia de Creative Commons Reconocimiento-NoComercial-CompartirIgual 4.0 Internacional</a>.

[Enllaç a Hackmk.io](https://hackmd.io/@JdaXaviQ/S1-ILmdxn)
## Laravel [00] (introducció).

### Instal·lació.
Teniu disponible, mitjançant desplegament, un escriptori d'Ubuntu amb PHP, Composer i Laravel instal·lats on podeu començar a utilitzar Laravel. Aquells que volgueu treballar en local, recordeu que en aquest mòdul treballem amb Ubuntu-Linux i que podeu seguir les instruccións d'instal·lació que trobareu a la [página oficial de Laravel.](https://laravel.com/docs/10.x/installation)

### Creació d'un projecte.
Per a començar, provarem a crear un projecte anomenat 'nom_projecte' dins de la carpeta '/home/isard/src', en cas de no existir, la haureu de crear primer.
A continuació executarem la sentència de _composer_ que genera un projecte de Laravel bàsic: 'composer create-project laravel/laravel nom_projecte':
```bash=
$ composer create-project laravel/laravel nom_projecte
Creating a "laravel/laravel" project at "./nom_projecte"
Installing laravel/laravel (v10.0.4)
  - Installing laravel/laravel (v10.0.4): Extracting archive
Created project in /home/isard/src/nom_projecte
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 106 installs, 0 updates, 0 removals
  - Locking brick/math (0.10.2)
  - Locking dflydev/dot-access-data (v3.0.2)
  - Locking doctrine/inflector (2.0.6)
  - Locking doctrine/lexer (3.0.0)
  - Locking dragonmantank/cron-expression (v3.3.2)
  - Locking egulias/email-validator (4.0.1)
  - Locking fakerphp/faker (v1.21.0)
  - Locking filp/whoops (2.15.1)
  - Locking fruitcake/php-cors (v1.2.0)
  - Locking graham-campbell/result-type (v1.1.1)
  - Locking guzzlehttp/guzzle (7.5.0)
  - Locking guzzlehttp/promises (1.5.2)
  - Locking guzzlehttp/psr7 (2.4.4)
  - Locking guzzlehttp/uri-template (v1.0.1)
  - Locking hamcrest/hamcrest-php (v2.0.1)
  - Locking laravel/framework (v10.4.1)
  - Locking laravel/pint (v1.7.0)
  - Locking laravel/sail (v1.21.2)
  - Locking laravel/sanctum (v3.2.1)
  - Locking laravel/serializable-closure (v1.3.0)
  - Locking laravel/tinker (v2.8.1)
  - Locking league/commonmark (2.3.9)
  - Locking league/config (v1.2.0)
  - Locking league/flysystem (3.12.3)
  - Locking league/mime-type-detection (1.11.0)
  - Locking mockery/mockery (1.5.1)
  - Locking monolog/monolog (3.3.1)
  - Locking myclabs/deep-copy (1.11.1)
  - Locking nesbot/carbon (2.66.0)
  - Locking nette/schema (v1.2.3)
  - Locking nette/utils (v4.0.0)
  - Locking nikic/php-parser (v4.15.4)
  - Locking nunomaduro/collision (v7.3.2)
  - Locking nunomaduro/termwind (v1.15.1)
  - Locking phar-io/manifest (2.0.3)
  - Locking phar-io/version (3.2.1)
  - Locking phpoption/phpoption (1.9.1)
  - Locking phpunit/php-code-coverage (10.0.2)
  - Locking phpunit/php-file-iterator (4.0.1)
  - Locking phpunit/php-invoker (4.0.0)
  - Locking phpunit/php-text-template (3.0.0)
  - Locking phpunit/php-timer (6.0.0)
  - Locking phpunit/phpunit (10.0.18)
  - Locking psr/container (2.0.2)
  - Locking psr/event-dispatcher (1.0.0)
  - Locking psr/http-client (1.0.1)
  - Locking psr/http-factory (1.0.1)
  - Locking psr/http-message (1.0.1)
  - Locking psr/log (3.0.0)
  - Locking psr/simple-cache (3.0.0)
  - Locking psy/psysh (v0.11.13)
  - Locking ralouphie/getallheaders (3.0.3)
  - Locking ramsey/collection (2.0.0)
  - Locking ramsey/uuid (4.7.3)
  - Locking sebastian/cli-parser (2.0.0)
  - Locking sebastian/code-unit (2.0.0)
  - Locking sebastian/code-unit-reverse-lookup (3.0.0)
  - Locking sebastian/comparator (5.0.0)
  - Locking sebastian/complexity (3.0.0)
  - Locking sebastian/diff (5.0.0)
  - Locking sebastian/environment (6.0.0)
  - Locking sebastian/exporter (5.0.0)
  - Locking sebastian/global-state (6.0.0)
  - Locking sebastian/lines-of-code (2.0.0)
  - Locking sebastian/object-enumerator (5.0.0)
  - Locking sebastian/object-reflector (3.0.0)
  - Locking sebastian/recursion-context (5.0.0)
  - Locking sebastian/type (4.0.0)
  - Locking sebastian/version (4.0.1)
  - Locking spatie/backtrace (1.4.0)
  - Locking spatie/flare-client-php (1.3.5)
  - Locking spatie/ignition (1.4.5)
  - Locking spatie/laravel-ignition (2.0.0)
  - Locking symfony/console (v6.2.7)
  - Locking symfony/css-selector (v6.2.7)
  - Locking symfony/deprecation-contracts (v3.2.1)
  - Locking symfony/error-handler (v6.2.7)
  - Locking symfony/event-dispatcher (v6.2.7)
  - Locking symfony/event-dispatcher-contracts (v3.2.1)
  - Locking symfony/finder (v6.2.7)
  - Locking symfony/http-foundation (v6.2.7)
  - Locking symfony/http-kernel (v6.2.7)
  - Locking symfony/mailer (v6.2.7)
  - Locking symfony/mime (v6.2.7)
  - Locking symfony/polyfill-ctype (v1.27.0)
  - Locking symfony/polyfill-intl-grapheme (v1.27.0)
  - Locking symfony/polyfill-intl-idn (v1.27.0)
  - Locking symfony/polyfill-intl-normalizer (v1.27.0)
  - Locking symfony/polyfill-mbstring (v1.27.0)
  - Locking symfony/polyfill-php72 (v1.27.0)
  - Locking symfony/polyfill-php80 (v1.27.0)
  - Locking symfony/polyfill-uuid (v1.27.0)
  - Locking symfony/process (v6.2.7)
  - Locking symfony/routing (v6.2.7)
  - Locking symfony/service-contracts (v3.2.1)
  - Locking symfony/string (v6.2.7)
  - Locking symfony/translation (v6.2.7)
  - Locking symfony/translation-contracts (v3.2.1)
  - Locking symfony/uid (v6.2.7)
  - Locking symfony/var-dumper (v6.2.7)
  - Locking symfony/yaml (v6.2.7)
  - Locking theseer/tokenizer (1.2.1)
  - Locking tijsverkoyen/css-to-inline-styles (2.2.6)
  - Locking vlucas/phpdotenv (v5.5.0)
  - Locking voku/portable-ascii (2.0.1)
  - Locking webmozart/assert (1.11.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 106 installs, 0 updates, 0 removals
  - Installing doctrine/inflector (2.0.6): Extracting archive
  - Installing doctrine/lexer (3.0.0): Extracting archive
  - Installing symfony/polyfill-ctype (v1.27.0): Extracting archive
  - Installing webmozart/assert (1.11.0): Extracting archive
  - Installing dragonmantank/cron-expression (v3.3.2): Extracting archive
  - Installing symfony/deprecation-contracts (v3.2.1): Extracting archive
  - Installing psr/container (2.0.2): Extracting archive
  - Installing fakerphp/faker (v1.21.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.27.0): Extracting archive
  - Installing symfony/http-foundation (v6.2.7): Extracting archive
  - Installing fruitcake/php-cors (v1.2.0): Extracting archive
  - Installing psr/http-message (1.0.1): Extracting archive
  - Installing psr/http-client (1.0.1): Extracting archive
  - Installing ralouphie/getallheaders (3.0.3): Extracting archive
  - Installing psr/http-factory (1.0.1): Extracting archive
  - Installing guzzlehttp/psr7 (2.4.4): Extracting archive
  - Installing guzzlehttp/promises (1.5.2): Extracting archive
  - Installing guzzlehttp/guzzle (7.5.0): Extracting archive
  - Installing symfony/polyfill-php80 (v1.27.0): Extracting archive
  - Installing guzzlehttp/uri-template (v1.0.1): Extracting archive
  - Installing laravel/pint (v1.7.0): Extracting archive
  - Installing symfony/yaml (v6.2.7): Extracting archive
  - Installing voku/portable-ascii (2.0.1): Extracting archive
  - Installing phpoption/phpoption (1.9.1): Extracting archive
  - Installing graham-campbell/result-type (v1.1.1): Extracting archive
  - Installing vlucas/phpdotenv (v5.5.0): Extracting archive
  - Installing symfony/css-selector (v6.2.7): Extracting archive
  - Installing tijsverkoyen/css-to-inline-styles (2.2.6): Extracting archive
  - Installing symfony/var-dumper (v6.2.7): Extracting archive
  - Installing symfony/polyfill-uuid (v1.27.0): Extracting archive
  - Installing symfony/uid (v6.2.7): Extracting archive
  - Installing symfony/routing (v6.2.7): Extracting archive
  - Installing symfony/process (v6.2.7): Extracting archive
  - Installing symfony/polyfill-php72 (v1.27.0): Extracting archive
  - Installing symfony/polyfill-intl-normalizer (v1.27.0): Extracting archive
  - Installing symfony/polyfill-intl-idn (v1.27.0): Extracting archive
  - Installing symfony/mime (v6.2.7): Extracting archive
  - Installing symfony/service-contracts (v3.2.1): Extracting archive
  - Installing psr/event-dispatcher (1.0.0): Extracting archive
  - Installing symfony/event-dispatcher-contracts (v3.2.1): Extracting archive
  - Installing symfony/event-dispatcher (v6.2.7): Extracting archive
  - Installing psr/log (3.0.0): Extracting archive
  - Installing egulias/email-validator (4.0.1): Extracting archive
  - Installing symfony/mailer (v6.2.7): Extracting archive
  - Installing symfony/error-handler (v6.2.7): Extracting archive
  - Installing symfony/http-kernel (v6.2.7): Extracting archive
  - Installing symfony/finder (v6.2.7): Extracting archive
  - Installing symfony/polyfill-intl-grapheme (v1.27.0): Extracting archive
  - Installing symfony/string (v6.2.7): Extracting archive
  - Installing symfony/console (v6.2.7): Extracting archive
  - Installing ramsey/collection (2.0.0): Extracting archive
  - Installing brick/math (0.10.2): Extracting archive
  - Installing ramsey/uuid (4.7.3): Extracting archive
  - Installing psr/simple-cache (3.0.0): Extracting archive
  - Installing nunomaduro/termwind (v1.15.1): Extracting archive
  - Installing symfony/translation-contracts (v3.2.1): Extracting archive
  - Installing symfony/translation (v6.2.7): Extracting archive
  - Installing nesbot/carbon (2.66.0): Extracting archive
  - Installing monolog/monolog (3.3.1): Extracting archive
  - Installing league/mime-type-detection (1.11.0): Extracting archive
  - Installing league/flysystem (3.12.3): Extracting archive
  - Installing nette/utils (v4.0.0): Extracting archive
  - Installing nette/schema (v1.2.3): Extracting archive
  - Installing dflydev/dot-access-data (v3.0.2): Extracting archive
  - Installing league/config (v1.2.0): Extracting archive
  - Installing league/commonmark (2.3.9): Extracting archive
  - Installing laravel/serializable-closure (v1.3.0): Extracting archive
  - Installing laravel/framework (v10.4.1): Extracting archive
  - Installing laravel/sail (v1.21.2): Extracting archive
  - Installing laravel/sanctum (v3.2.1): Extracting archive
  - Installing nikic/php-parser (v4.15.4): Extracting archive
  - Installing psy/psysh (v0.11.13): Extracting archive
  - Installing laravel/tinker (v2.8.1): Extracting archive
  - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive
  - Installing mockery/mockery (1.5.1): Extracting archive
  - Installing filp/whoops (2.15.1): Extracting archive
  - Installing nunomaduro/collision (v7.3.2): Extracting archive
  - Installing sebastian/version (4.0.1): Extracting archive
  - Installing sebastian/type (4.0.0): Extracting archive
  - Installing sebastian/recursion-context (5.0.0): Extracting archive
  - Installing sebastian/object-reflector (3.0.0): Extracting archive
  - Installing sebastian/object-enumerator (5.0.0): Extracting archive
  - Installing sebastian/global-state (6.0.0): Extracting archive
  - Installing sebastian/exporter (5.0.0): Extracting archive
  - Installing sebastian/environment (6.0.0): Extracting archive
  - Installing sebastian/diff (5.0.0): Extracting archive
  - Installing sebastian/comparator (5.0.0): Extracting archive
  - Installing sebastian/code-unit (2.0.0): Extracting archive
  - Installing sebastian/cli-parser (2.0.0): Extracting archive
  - Installing phpunit/php-timer (6.0.0): Extracting archive
  - Installing phpunit/php-text-template (3.0.0): Extracting archive
  - Installing phpunit/php-invoker (4.0.0): Extracting archive
  - Installing phpunit/php-file-iterator (4.0.1): Extracting archive
  - Installing theseer/tokenizer (1.2.1): Extracting archive
  - Installing sebastian/lines-of-code (2.0.0): Extracting archive
  - Installing sebastian/complexity (3.0.0): Extracting archive
  - Installing sebastian/code-unit-reverse-lookup (3.0.0): Extracting archive
  - Installing phpunit/php-code-coverage (10.0.2): Extracting archive
  - Installing phar-io/version (3.2.1): Extracting archive
  - Installing phar-io/manifest (2.0.3): Extracting archive
  - Installing myclabs/deep-copy (1.11.1): Extracting archive
  - Installing phpunit/phpunit (10.0.18): Extracting archive
  - Installing spatie/backtrace (1.4.0): Extracting archive
  - Installing spatie/flare-client-php (1.3.5): Extracting archive
  - Installing spatie/ignition (1.4.5): Extracting archive
  - Installing spatie/laravel-ignition (2.0.0): Extracting archive
62 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   INFO  Discovering packages.  

  laravel/sail ................................................................................................................................ DONE
  laravel/sanctum ............................................................................................................................. DONE
  laravel/tinker .............................................................................................................................. DONE
  nesbot/carbon ............................................................................................................................... DONE
  nunomaduro/collision ........................................................................................................................ DONE
  nunomaduro/termwind ......................................................................................................................... DONE
  spatie/laravel-ignition ..................................................................................................................... DONE

80 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force

   INFO  No publishable resources for tag [laravel-assets].  

No security vulnerability advisories found
> @php artisan key:generate --ansi

   INFO  Application key set successfully.  
```
Com es pot apreciar composer genera una sortida de text prolífica on ens indica totes les dependències instal·lades, els paquets que tenim disponibles, les vulnerabilitats conegudes i que ens ha generat una key d'aplicació per al nostre projecte.
Si entrem dins de la carpeta ./nom_projecte que s'acaba de crear, observarem que s'han generat un munt de fitxers i directoris que composen la nostra aplicació, entre ells un amb permisos d'execució anomenat __artisan__. Ja anirem coneixen al nostre amic artisan durant les properes setmanes, de moment només ens cal saber que si executem la ordre:
```bash=
$ php artisan serve

   INFO  Server running on [http://127.0.0.1:8000].  

  Press Ctrl+C to stop the server
```
Ens arrenca un servidor web de desenvolupament on podem accedir a la nostra app.
![](https://i.imgur.com/pFTLee9.png)
