yakoffka.ru
    грабли, костыли и велосипеды php, css, html, js и прочего

    Создание интернет-витрины на laravel. Часть 1

    laravel.

    Капустин Яков

    оглавление

    Прописываем новый сайт в конфигурационном файле виртуальной машины Homestead:

    /home/username/Homestead/Homestead.yaml:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42

    ---
    ip"192.168.10.10"
    memory1024
    cpus
    1
    provider
    virtualbox

    authorize
    : ~/.ssh/id_rsa.pub

    keys
    :
        - ~/.
    ssh/id_rsa

    folders
    :
        - 
    map: ~/projects
          to
    : /home/vagrant/projects

    sites
    :  
        - 
    mapkk.local
          to
    : /home/vagrant/projects/kk/public

    databases:
        - 
    kk_db

    # ports:
    #   - send: 50000
    #     to: 5000
    #   - send: 7777
    #     to: 777
    #     protocol: udp

    # blackfire:
    #   - id: foo
    #     token: bar
    #     client-id: foo
    #     client-token: bar

    # zray:
    #  If you've already freely registered Z-Ray, you can place the token here.
    #   - email: foo@bar.com
    #     token: foo
    #  Don't forget to ensure that you have 'zray: "true"' for your site.
      

    и в /etc/hosts:

    /etc/hosts:
    1
    2
    3
    4
    5

    ...

    192.168.10.10 kk.local

    В виртуальной машине Homestead создаём новое приложение с помощью composer.

    bash:
    vagrant@homestead:~/projects$ composer create-project --prefer-dist laravel/laravel kk 1/12: http://repo.packagist.org/p/provider-archived$4a5c3e1a288f5c1e67b11022fab4d7110205a27cc0d7259e55ac2f05ebd0453d.json 2/12: http://repo.packagist.org/p/provider-latest$336f96b426f92b1c3cbc74e212abbffa576dabd373f6234cad5e844c45fc6d7c.json 3/12: http://repo.packagist.org/p/provider-2016$e844d70ddc3cdbd8d6df77c07e6fd806911b217da3b306a99eca064b69aca6f3.json 4/12: http://repo.packagist.org/p/provider-2019-04$6c0d447450489df880301f8b5e89c34665e906306fd78706dc45186bfc004244.json 5/12: http://repo.packagist.org/p/provider-2013$b49140642597a21446ba782b4624d1c9c7b9561176c0256205b33f4394fa2333.json 7/12: http://repo.packagist.org/p/provider-2018-07$e0a4e2264029fabbc3f7d47a7b7d8b594bb33613c6f19724434fd8d317822fd2.json 7/12: http://repo.packagist.org/p/provider-2014$d9fe4f44b35b23ce64e39433ff864b7ba7633759e8a74477eafe3aea4cc1e7dd.json 8/12: http://repo.packagist.org/p/provider-2018$941df240a33cb17e721eb6ad6d80077198c38cbcb6037b7fbf29319a69a8c4db.json 9/12: http://repo.packagist.org/p/provider-2017$91aa31099ac4a65662589930fb98563afefe4a61179b65328eca5cdb9616b011.json 10/12: http://repo.packagist.org/p/provider-2015$e76814f30149ad3e4f6c38938bb5694012b983e0eb383cd86dcfc0ba041750c5.json 11/12: http://repo.packagist.org/p/provider-2018-10$c65d66f9a51c2f87bf2bf3613fdae557de11b7ec004b79cd8aa9d0b71ff575ad.json 12/12: http://repo.packagist.org/p/provider-2019-01$7b2911fb2c021462fbf5858a49fa18553a105d6bae0a41e91d5eab17860dffc9.json Finished: success: 12, skipped: 0, failure: 0, total: 12 1/12: http://repo.packagist.org/p/provider-archived$4a5c3e1a288f5c1e67b11022fab4d7110205a27cc0d7259e55ac2f05ebd0453d.json 2/12: http://repo.packagist.org/p/provider-2015$e76814f30149ad3e4f6c38938bb5694012b983e0eb383cd86dcfc0ba041750c5.json 3/12: http://repo.packagist.org/p/provider-2014$d9fe4f44b35b23ce64e39433ff864b7ba7633759e8a74477eafe3aea4cc1e7dd.json 4/12: http://repo.packagist.org/p/provider-2018-07$e0a4e2264029fabbc3f7d47a7b7d8b594bb33613c6f19724434fd8d317822fd2.json 5/12: http://repo.packagist.org/p/provider-2013$b49140642597a21446ba782b4624d1c9c7b9561176c0256205b33f4394fa2333.json 6/12: http://repo.packagist.org/p/provider-2018-10$c65d66f9a51c2f87bf2bf3613fdae557de11b7ec004b79cd8aa9d0b71ff575ad.json 7/12: http://repo.packagist.org/p/provider-latest$336f96b426f92b1c3cbc74e212abbffa576dabd373f6234cad5e844c45fc6d7c.json 8/12: http://repo.packagist.org/p/provider-2018$941df240a33cb17e721eb6ad6d80077198c38cbcb6037b7fbf29319a69a8c4db.json 9/12: http://repo.packagist.org/p/provider-2019-04$6c0d447450489df880301f8b5e89c34665e906306fd78706dc45186bfc004244.json 10/12: http://repo.packagist.org/p/provider-2016$e844d70ddc3cdbd8d6df77c07e6fd806911b217da3b306a99eca064b69aca6f3.json 11/12: http://repo.packagist.org/p/provider-2019-01$7b2911fb2c021462fbf5858a49fa18553a105d6bae0a41e91d5eab17860dffc9.json 12/12: http://repo.packagist.org/p/provider-2017$91aa31099ac4a65662589930fb98563afefe4a61179b65328eca5cdb9616b011.json Finished: success: 12, skipped: 0, failure: 0, total: 12 Installing laravel/laravel (v5.8.17) - Installing laravel/laravel (v5.8.17): Downloading (100%) Created project in kk > @php -r "file_exists('.env') || copy('.env.example', '.env');" Loading composer repositories with package information Updating dependencies (including require-dev) 1/68: https://codeload.github.com/phpDocumentor/ReflectionCommon/legacy.zip/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6 2/68: https://codeload.github.com/webmozart/assert/legacy.zip/83e253c8e0be5b0257b881e1827274667c5c17a9 3/68: https://codeload.github.com/phpDocumentor/TypeResolver/legacy.zip/9c977708995954784726e25d0cd1dddf4e65b0f7 4/68: https://codeload.github.com/doctrine/instantiator/legacy.zip/a2c590166b2133a4633738648b6b064edae0814a 5/68: https://codeload.github.com/phar-io/version/legacy.zip/45a2ec53a73c70ce41d55cedef9063630abaf1b6 6/68: https://codeload.github.com/sebastianbergmann/code-unit-reverse-lookup/legacy.zip/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18 7/68: https://codeload.github.com/theseer/tokenizer/legacy.zip/1c42705be2b6c1de5904f8afacef5895cab44bf8 8/68: https://codeload.github.com/sebastianbergmann/php-token-stream/legacy.zip/c99e3be9d3e85f60646f152f9002d46ed7770d18 9/68: https://codeload.github.com/myclabs/DeepCopy/legacy.zip/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72 10/68: https://codeload.github.com/phar-io/manifest/legacy.zip/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4 11/68: https://codeload.github.com/sebastianbergmann/php-text-template/legacy.zip/31f8b717e51d9a2afca6c9f046f5d69fc27c8686 12/68: https://codeload.github.com/sebastianbergmann/php-file-iterator/legacy.zip/050bedf145a257b1ff02746c31894800e5122946 13/68: https://codeload.github.com/phpDocumentor/ReflectionDocBlock/legacy.zip/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c 14/68: https://codeload.github.com/sebastianbergmann/php-timer/legacy.zip/8b389aebe1b8b0578430bda0c7c95a829608e059 15/68: https://codeload.github.com/phpspec/prophecy/legacy.zip/4ba436b55987b4bf311cb7c6ba82aa528aac0a06 16/68: https://codeload.github.com/sebastianbergmann/comparator/legacy.zip/5de4fc177adf9bce8df98d8d141a7559d7ccf6da 17/68: https://codeload.github.com/sebastianbergmann/environment/legacy.zip/f2a2c8e1c97c11ace607a7a667d73d47c19fe404 18/68: https://codeload.github.com/sebastianbergmann/exporter/legacy.zip/234199f4528de6d12aaa58b612e98f7d36adb937 19/68: https://codeload.github.com/sebastianbergmann/global-state/legacy.zip/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4 20/68: https://codeload.github.com/sebastianbergmann/recursion-context/legacy.zip/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8 21/68: https://codeload.github.com/sebastianbergmann/object-reflector/legacy.zip/773f97c67f28de00d397be301821b06708fca0be 22/68: https://codeload.github.com/sebastianbergmann/resource-operations/legacy.zip/4d7a795d35b889bf80a0cc04e08d77cedfa917a9 23/68: https://codeload.github.com/sebastianbergmann/version/legacy.zip/99732be0ddb3361e16ad77b68ba41efc8e979019 24/68: https://codeload.github.com/nunomaduro/collision/legacy.zip/af42d339fe2742295a54f6fdd42aaa6f8c4aca68 25/68: https://codeload.github.com/sebastianbergmann/php-code-coverage/legacy.zip/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d 26/68: https://codeload.github.com/laravel/tinker/legacy.zip/cafbf598a90acde68985660e79b2b03c5609a405 27/68: https://codeload.github.com/dnoegel/php-xdg-base-dir/legacy.zip/265b8593498b997dc2d31e75b89f053b5cc9621a 28/68: https://codeload.github.com/JakubOnderka/PHP-Console-Highlighter/legacy.zip/9f7a229a69d52506914b4bc61bfdb199d90c5547 29/68: https://codeload.github.com/JakubOnderka/PHP-Console-Color/legacy.zip/d5deaecff52a0d61ccb613bb3804088da0307191 30/68: https://codeload.github.com/sebastianbergmann/diff/legacy.zip/720fcc7e9b5cf384ea68d9d930d480907a0c1a29 31/68: https://codeload.github.com/fideloper/TrustedProxy/legacy.zip/177c79a2d1f9970f89ee2fb4c12b429af38b6dfb 32/68: https://codeload.github.com/beyondcode/laravel-dump-server/legacy.zip/8864b9efcb48e0a79e83014dd7f0a5481f5c808f 33/68: https://codeload.github.com/sebastianbergmann/object-enumerator/legacy.zip/7cfd9e65d11ffb5af41198476395774d4c8a84c5 34/68: https://codeload.github.com/dragonmantank/cron-expression/legacy.zip/72b6fbf76adb3cf5bc0db68559b33d41219aba27 35/68: https://codeload.github.com/hamcrest/hamcrest-php/legacy.zip/776503d3a8e85d4f9a1148614f95b7a608b046ad 36/68: https://codeload.github.com/mockery/mockery/legacy.zip/0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2 37/68: https://codeload.github.com/erusev/parsedown/legacy.zip/6d893938171a817f4e9bc9e86f2da1e370b7bcd7 38/68: https://codeload.github.com/thephpleague/flysystem/legacy.zip/755ba7bf3fb9031e6581d091db84d78275874396 39/68: https://codeload.github.com/sebastianbergmann/phpunit/legacy.zip/64cb33f5b520da490a7b13149d39b43cf3c890c6 40/68: https://codeload.github.com/opis/closure/legacy.zip/09b4389715a7eec100176ea58286649181753508 41/68: https://codeload.github.com/filp/whoops/legacy.zip/bc0fd11bc455cc20ee4b5edabc63ebbf859324c7 42/68: https://codeload.github.com/paragonie/random_compat/legacy.zip/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95 43/68: https://codeload.github.com/nikic/PHP-Parser/legacy.zip/5221f49a608808c1e4d436df32884cbc1b821ac0 44/68: https://codeload.github.com/doctrine/lexer/legacy.zip/83893c552fd2045dd78aef794c31e694c37c0b8c 45/68: https://codeload.github.com/Seldaek/monolog/legacy.zip/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266 46/68: https://codeload.github.com/egulias/EmailValidator/legacy.zip/709f21f92707308cdf8f9bcfa1af4cb26586521e 47/68: https://codeload.github.com/symfony/translation/legacy.zip/181a426dd129cb496f12d7e7555f6d0b37a7615b 48/68: https://codeload.github.com/ramsey/uuid/legacy.zip/d09ea80159c1929d75b3f9c60504d613aeb4a1e3 49/68: https://codeload.github.com/bobthecow/psysh/legacy.zip/9aaf29575bb8293206bb0420c1e1c87ff2ffa94e 50/68: https://codeload.github.com/symfony/polyfill-intl-idn/legacy.zip/c766e95bec706cdd89903b1eda8afab7d7a6b7af 51/68: https://codeload.github.com/symfony/contracts/legacy.zip/d3636025e8253c6144358ec0a62773cae588395b 52/68: https://codeload.github.com/php-fig/log/legacy.zip/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd 53/68: https://codeload.github.com/symfony/http-foundation/legacy.zip/1ea878bd3af18f934dedb8c0de60656a9a31a718 54/68: https://codeload.github.com/symfony/debug/legacy.zip/2d279b6bb1d582dd5740d4d3251ae8c18812ed37 55/68: https://codeload.github.com/symfony/var-dumper/legacy.zip/3c4084cb1537c0e2ad41aad622bbf55a44a5c9ce 56/68: https://codeload.github.com/symfony/http-kernel/legacy.zip/a7713bc522f1a1cdf0b39f809fa4542523fc3114 57/68: https://codeload.github.com/tijsverkoyen/CssToInlineStyles/legacy.zip/0ed4a2ea4e0902dac0489e6436ebcd5bbcae9757 58/68: https://codeload.github.com/vlucas/phpdotenv/legacy.zip/dbcc609971dd9b55f48b8008b553d79fd372ddde 59/68: https://codeload.github.com/symfony/polyfill-php72/legacy.zip/ab50dcf166d5f577978419edd37aa2bb8eabce0c 60/68: https://codeload.github.com/symfony/routing/legacy.zip/f4e43bb0dff56f0f62fa056c82d7eadcdb391bab 61/68: https://codeload.github.com/schmittjoh/php-option/legacy.zip/94e644f7d2051a5f0fcf77d81605f152eecff0ed 62/68: https://codeload.github.com/symfony/css-selector/legacy.zip/48eddf66950fa57996e1be4a55916d65c10c604a 63/68: https://codeload.github.com/symfony/polyfill-iconv/legacy.zip/f037ea22acfaee983e271dd9c3b8bb4150bd8ad7 64/68: https://codeload.github.com/symfony/event-dispatcher/legacy.zip/fbce53cd74ac509cbe74b6f227622650ab759b02 65/68: https://codeload.github.com/swiftmailer/swiftmailer/legacy.zip/5397cd05b0a0f7937c47b0adcb4c60e5ab936b6a 66/68: https://codeload.github.com/briannesbitt/Carbon/legacy.zip/96acbc0c03782e8115156dd4dd8b736267155066 67/68: https://codeload.github.com/laravel/framework/legacy.zip/33c04dd2a431adeeb49926a4f2b20590cc033ca2 68/68: https://codeload.github.com/fzaninotto/Faker/legacy.zip/f72816b43e74063c8b10357394b6bba8cb1c10de Finished: success: 68, skipped: 0, failure: 0, total: 68 Package operations: 76 installs, 0 updates, 0 removals - Installing symfony/polyfill-ctype (v1.11.0): Loading from cache - Installing phpoption/phpoption (1.5.0): Loading from cache - Installing vlucas/phpdotenv (v3.3.3): Loading from cache - Installing symfony/css-selector (v4.2.8): Loading from cache - Installing tijsverkoyen/css-to-inline-styles (2.2.1): Loading from cache - Installing symfony/polyfill-php72 (v1.11.0): Loading from cache - Installing symfony/polyfill-mbstring (v1.11.0): Loading from cache - Installing symfony/var-dumper (v4.2.8): Loading from cache - Installing symfony/routing (v4.2.8): Loading from cache - Installing symfony/process (v4.2.8): Loading from cache - Installing psr/log (1.1.0): Loading from cache - Installing symfony/debug (v4.2.8): Loading from cache - Installing symfony/polyfill-intl-idn (v1.11.0): Loading from cache - Installing symfony/http-foundation (v4.2.8): Loading from cache - Installing symfony/contracts (v1.1.0): Loading from cache - Installing symfony/event-dispatcher (v4.2.8): Loading from cache - Installing symfony/http-kernel (v4.2.8): Loading from cache - Installing symfony/finder (v4.2.8): Loading from cache - Installing symfony/console (v4.2.8): Loading from cache - Installing symfony/polyfill-iconv (v1.11.0): Loading from cache - Installing doctrine/lexer (v1.0.1): Loading from cache - Installing egulias/email-validator (2.1.7): Loading from cache - Installing swiftmailer/swiftmailer (v6.2.1): Loading from cache - Installing paragonie/random_compat (v9.99.99): Loading from cache - Installing ramsey/uuid (3.8.0): Loading from cache - Installing psr/simple-cache (1.0.1): Loading from cache - Installing psr/container (1.0.0): Loading from cache - Installing opis/closure (3.2.0): Loading from cache - Installing symfony/translation (v4.2.8): Loading from cache - Installing nesbot/carbon (2.17.1): Loading from cache - Installing monolog/monolog (1.24.0): Loading from cache - Installing league/flysystem (1.0.51): Loading from cache - Installing erusev/parsedown (1.7.3): Loading from cache - Installing dragonmantank/cron-expression (v2.3.0): Loading from cache - Installing nikic/php-parser (v4.2.1): Loading from cache - Installing doctrine/inflector (v1.3.0): Loading from cache - Installing laravel/framework (v5.8.17): Loading from cache - Installing fideloper/proxy (4.1.0): Loading from cache - Installing beyondcode/laravel-dump-server (1.2.2): Loading from cache - Installing jakub-onderka/php-console-color (v0.2): Loading from cache - Installing jakub-onderka/php-console-highlighter (v0.4): Loading from cache - Installing dnoegel/php-xdg-base-dir (0.1): Loading from cache - Installing psy/psysh (v0.9.9): Loading from cache - Installing laravel/tinker (v1.0.8): Loading from cache - Installing fzaninotto/faker (v1.8.0): Loading from cache - Installing hamcrest/hamcrest-php (v2.0.0): Loading from cache - Installing mockery/mockery (1.2.2): Loading from cache - Installing filp/whoops (2.3.1): Loading from cache - Installing nunomaduro/collision (v3.0.1): Loading from cache - Installing sebastian/version (2.0.1): Loading from cache - Installing sebastian/resource-operations (2.0.1): Loading from cache - Installing sebastian/object-reflector (1.1.1): Loading from cache - Installing sebastian/recursion-context (3.0.0): Loading from cache - Installing sebastian/object-enumerator (3.0.3): Loading from cache - Installing sebastian/global-state (2.0.0): Loading from cache - Installing sebastian/exporter (3.1.0): Loading from cache - Installing sebastian/environment (4.2.2): Loading from cache - Installing sebastian/diff (3.0.2): Loading from cache - Installing sebastian/comparator (3.0.2): Loading from cache - Installing phpunit/php-timer (2.1.1): Loading from cache - Installing phpunit/php-text-template (1.2.1): Loading from cache - Installing phpunit/php-file-iterator (2.0.2): Loading from cache - Installing theseer/tokenizer (1.1.2): Loading from cache - Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache - Installing phpunit/php-token-stream (3.0.1): Loading from cache - Installing phpunit/php-code-coverage (6.1.4): Loading from cache - Installing doctrine/instantiator (1.2.0): Loading from cache - Installing webmozart/assert (1.4.0): Loading from cache - Installing phpdocumentor/reflection-common (1.0.1): Loading from cache - Installing phpdocumentor/type-resolver (0.4.0): Loading from cache - Installing phpdocumentor/reflection-docblock (4.3.1): Loading from cache - Installing phpspec/prophecy (1.8.0): Loading from cache - Installing phar-io/version (2.0.1): Loading from cache - Installing phar-io/manifest (1.0.3): Loading from cache - Installing myclabs/deep-copy (1.9.1): Loading from cache - Installing phpunit/phpunit (7.5.11): Loading from cache symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader) symfony/routing suggests installing symfony/yaml (For using the YAML loader) symfony/routing suggests installing symfony/expression-language (For using expression matching) symfony/routing suggests installing doctrine/annotations (For using the annotation loader) symfony/contracts suggests installing psr/cache (When using the Cache contracts) symfony/contracts suggests installing symfony/cache-contracts-implementation symfony/contracts suggests installing symfony/event-dispatcher-implementation symfony/contracts suggests installing symfony/http-client-contracts-implementation symfony/contracts suggests installing symfony/service-contracts-implementation symfony/event-dispatcher suggests installing symfony/dependency-injection symfony/http-kernel suggests installing symfony/browser-kit symfony/http-kernel suggests installing symfony/config symfony/http-kernel suggests installing symfony/dependency-injection symfony/console suggests installing symfony/lock swiftmailer/swiftmailer suggests installing true/punycode (Needed to support internationalized email addresses, if ext-intl is not installed) paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.) ramsey/uuid suggests installing ircmaxell/random-lib (Provides RandomLib for use with the RandomLibAdapter) ramsey/uuid suggests installing ext-libsodium (Provides the PECL libsodium extension for use with the SodiumRandomGenerator) ramsey/uuid suggests installing ext-uuid (Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator) ramsey/uuid suggests installing moontoast/math (Provides support for converting UUID to 128-bit integer (in string form).) ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.) ramsey/uuid suggests installing ramsey/uuid-console (A console application for generating UUIDs with ramsey/uuid) symfony/translation suggests installing symfony/config symfony/translation suggests installing symfony/yaml monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server) monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server) monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server) monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server) monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib) monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required)) monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server) monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver) monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB) monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar) monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome) league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem) league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files) league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage) league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage) league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2) league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3) league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage) league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications) league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching) league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib) league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter) laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver and SES mail driver (^3.0).) laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (^2.6).) laravel/framework suggests installing guzzlehttp/guzzle (Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (^6.0).) laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (^1.0).) laravel/framework suggests installing league/flysystem-cached-adapter (Required to use the Flysystem cache (^1.0).) laravel/framework suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (^1.0).) laravel/framework suggests installing league/flysystem-sftp (Required to use the Flysystem SFTP driver (^1.0).) laravel/framework suggests installing moontoast/math (Required to use ordered UUIDs (^1.1).) laravel/framework suggests installing nexmo/client (Required to use the Nexmo transport (^1.0).) laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (^4.0).) laravel/framework suggests installing predis/predis (Required to use the redis cache and queue drivers (^1.0).) laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (^3.0).) laravel/framework suggests installing symfony/dom-crawler (Required to use most of the crawler integration testing tools (^4.2).) laravel/framework suggests installing symfony/psr-http-message-bridge (Required to use PSR-7 bridging features (^1.1).) laravel/framework suggests installing wildbit/swiftmailer-postmark (Required to use Postmark mail driver (^3.0).) psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.) psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You\'ll want this if your PHP install doesn\'t already support readline or libedit.) filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses) sebastian/global-state suggests installing ext-uopz (*) phpunit/php-code-coverage suggests installing ext-xdebug (^2.6.0) phpunit/phpunit suggests installing phpunit/php-invoker (^2.0) phpunit/phpunit suggests installing ext-xdebug (*) Writing lock file Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Discovered Package: beyondcode/laravel-dump-server Discovered Package: fideloper/proxy Discovered Package: laravel/tinker Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Package manifest generated successfully. > @php artisan key:generate --ansi Application key set successfully. vagrant@homestead:~/projects$

    После разворачивания проекта прописываем необходимые настройки в конфигурационном файле проекта '.env' (APP_NAME, APP_KEY, DB_DATABASE, DB_USERNAME, DB_PASSWORD и др. ).

    bash:
    vagrant@homestead:~$ cd projects/kk/ vagrant@homestead:~/projects/kk$ php artisan make:auth Authentication scaffolding generated successfully. vagrant@homestead:~/projects/kk$ php artisan migrate Migration table created successfully. Migrating: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_000000_create_users_table Migrating: 2014_10_12_100000_create_password_resets_table Migrated: 2014_10_12_100000_create_password_resets_table vagrant@homestead:~/projects/kk$

    Создание файла миграции для товаров:

    bash:
    vagrant@homestead:~/projects/kk$ php artisan make:migration create_products_table Created Migration: 2019_05_17_163750_create_products_table vagrant@homestead:~/projects/kk$
    database/migrations/2019_05_17_163750_create_products_table.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34

    <?php

    use Illuminate\Support\Facades\Schema;
    use 
    Illuminate\Database\Schema\Blueprint;
    use 
    Illuminate\Database\Migrations\Migration;

    class 
    CreateProductsTable extends Migration
    {
      
    /**
       * Run the migrations.
       *
       * @return void
       */
      
    public function up()
      {
        
    Schema::create('products', function (Blueprint $table) {
          
    $table->bigIncrements('id');
          
    $table->timestamps();
        });
      }

      
    /**
       * Reverse the migrations.
       *
       * @return void
       */
      
    public function down()
      {
        
    Schema::dropIfExists('products');
      }
    }

    Добавим поля в создаваемую с помощью данной миграции таблицу:

    измененный database/migrations/2019_05_17_163750_create_products_table.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42

    <?php

    use Illuminate\Support\Facades\Schema;
    use 
    Illuminate\Database\Schema\Blueprint;
    use 
    Illuminate\Database\Migrations\Migration;

    class 
    CreateProductsTable extends Migration
    {
      
    /**
       * Run the migrations.
       *
       * @return void
       */
      
    public function up()
      {
        
    Schema::create('products', function (Blueprint $table) {
          
    $table->bigIncrements('id');
          
    $table->string('name');
          
    $table->string('manufacturer')->nullable();
          
    $table->string('materials')->nullable();
          
    $table->text('description')->nullable();
          
    $table->integer('image_id')->nullable();
          
    $table->integer('year_manufacture')->nullable();
          
    $table->float('price'82)->nullable();
          
    $table->integer('added_by_user_id');
          
    $table->integer('edited_by_user_id')->nullable(); // upd!
          
    $table->timestamps();
        });
      }

      
    /**
       * Reverse the migrations.
       *
       * @return void
       */
      
    public function down()
      {
        
    Schema::dropIfExists('products');
      }
    }

    Создание модели Product:

    bash:
    vagrant@homestead:~/projects/kk$ php artisan make:model Product Model created successfully. vagrant@homestead:~/projects/kk$
    app/Product.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13

    <?php

    namespace App;

    use 
    Illuminate\Database\Eloquent\Model;

    class 
    Product extends Model
    {
      
    //
    }

    Создание контроллера ProductsController:

    bash:
    vagrant@homestead:~/projects/kk$ php artisan make:controller ProductsController Controller created successfully. vagrant@homestead:~/projects/kk$
    app/Http/Controllers/ProductsController.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13

    <?php

    namespace App\Http\Controllers;

    use 
    Illuminate\Http\Request;

    class 
    ProductsController extends Controller
    {
      
    //
    }

    Опишем в контроллере метод index:

    app/Http/Controllers/ProductsController.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17

    <?php

    namespace App\Http\Controllers;

    use 
    Illuminate\Http\Request;

    use 
    App\Product;

    class 
    ProductsController extends Controller
    {
      public function 
    index() {
        
    $products Product::all();
        return 
    view('products.index'compact('products'));
    }
    }

    Добавление маршрута:

    routes/web.php:
    1
    2
    3
    4
    5

    ...

    Route::get('/products''ProductsController@index');

    Создадим файл вида:

    resources/views/products/index.blade.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25

    @extends('layouts.app')

    @
    section('content')
    <
    div class="container">
      <
    div class="row justify-content-center">
        <
    h1>Products</h1>
      </
    div>

      <
    div class="row">

        @foreach(
    $products as $product)

        <
    div class="col-sm-4 product_card_bm">
          <
    div class="card">
            <
    h5>{{ $product->name }}</h5>
          </
    div>
        </
    div>

        @endforeach

      </
    div>
    </
    div>
    @
    endsection

    Для генерирования тестовых товаров создадим ProductsTableSeeder:

    bash:
    vagrant@homestead:~/projects/kk$ php artisan make:seeder ProductsTableSeeder Seeder created successfully. vagrant@homestead:~/projects/kk$
    database/seeds/ProductsTableSeeder.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18

    <?php

    use Illuminate\Database\Seeder;

    class 
    ProductsTableSeeder extends Seeder
    {
      
    /**
       * Run the database seeds.
       *
       * @return void
       */
      
    public function run()
      {
        
    //
      
    }
    }

    и опишем в нем метод run():

    database/seeds/ProductsTableSeeder.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47

    <?php

    use Illuminate\Database\Seeder;

    class 
    ProductsTableSeeder extends Seeder
    {
      
    /**
       * Run the database seeds.
       *
       * @return void
       */
      
    public function run()
      {
        
    $arrManuf = ['Cort''Fernandes''Epiphone''Fender', ];
        
    $arrType = ['Bass''Acoustic''Electric', ];
        
    $arrMaterial = ['Basswood''Maple''Birch''Cast iron', ];
        
    $a 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

        for (
    $i=0$i<24$i++) {

          
    $manufacturer $arrManuf[rand(0count($arrManuf)-1)];
          
    $name $manufacturer
            
    ' '
            
    $arrType[rand(0count($arrType)-1)] 
            . 
    ' Guitar ' 
            
    $a[rand(0strlen($a)-1)] 
            . 
    $a[rand(0strlen($a)-1)] 
            . 
    '-' 
            
    rand(5215);
          
    $materials $arrMaterial[rand(0count($arrMaterial)-1)];


          
    DB::table('products')->insert([
            
    'name' => $name,
            
    'manufacturer' => $manufacturer,
            
    'materials' => $materials,
            
    'description' => 'lorem ipsum, quia dolor sit amet consectetur adipiscing velit, sed quia non-numquam do eius modi tempora incididunt, ut labore et dolore magnam aliquam quaerat voluptatem.',
            
    'year_manufacture' => '2018',
            
    'price' => rand(20000,32000),
            
    'added_by_user_id' => 1,
          ]);
        }

      }
    }

    Добавим данный класс в файл 'database/seeds/DatabaseSeeder.php' для полной перестройки базы данных в последующем с помощью команды 'php artisan migrate:refresh --seed':

    database/seeds/DatabaseSeeder.php:
    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22

    <?php

    use Illuminate\Database\Seeder;

    class 
    DatabaseSeeder extends Seeder
    {
      
    /**
       * Seed the application's database.
       *
       * @return void
       */
      
    public function run()
      {
        
    // $this->call(UsersTableSeeder::class);

        
    $this->call([
          
    ProductsTableSeeder::class,
        ]);
      }
    }

    Выполним 'php artisan migrate:refresh --seed':

    bash:
    vagrant@homestead:~/projects/kk$ php artisan migrate:refresh --seed Rolling back: 2019_05_17_163750_create_products_table Rolled back: 2019_05_17_163750_create_products_table Rolling back: 2014_10_12_100000_create_password_resets_table Rolled back: 2014_10_12_100000_create_password_resets_table Rolling back: 2014_10_12_000000_create_users_table Rolled back: 2014_10_12_000000_create_users_table Migrating: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_000000_create_users_table Migrating: 2014_10_12_100000_create_password_resets_table Migrated: 2014_10_12_100000_create_password_resets_table Migrating: 2019_05_17_163750_create_products_table Migrated: 2019_05_17_163750_create_products_table Seeding: ProductsTableSeeder Database seeding completed successfully. vagrant@homestead:~/projects/kk$

    Немного подправим вид и стили - и можно смотреть первые результаты. Исходники можно скачать здесь.

    Рис. 1 первый результат
    Рис. 1 первый результат