Skill Level
Intermediate
Categories
Web Development
Reading Time
36 minutes, 8 seconds
Technology
PHP
Framework
Laravel
Library
No library
Teach Me Laravel Pt.2 – Instalasi Laravel

Sebelumnya kita sudah berkenalan dengan Laravel. Secara singkat Laravel adalah sebuah framework PHP memiliki arsitektur MVC yang dibuat oleh Taylor Otwell, tahun rilis pertamanya adalah 2011.

Hari ini kita akan membuat project pertama dengan Laravel. Sebelumnya, untuk memulai men-develop Laravel kamu memerlukan pemahaman tentang PHP dan menginstal local development environment untuk PHP. Kamu bisa baca artikel ini untuk setup PHP local development environment:

 

Instalasi Laravel

Pertama, kita akan memahami dulu cara instalasi Laravel. Karena, untuk menginstal atau memulai membuat project baru dengan Laravel kamu harus menggunakan Composer untuk mengunduh semua dependencies nya.

Pada tutorial ini kita akan menggunakan Laravel versi 5.5 karena versi tersebut adalah versi terbaru untuk saat ini. Adapun beberapa kebutuhan yang harus kamu ikuti untuk memulai men-develop Laravel dengan versi 5.5, kebutuhannya yaitu:

  • PHP >= 7.0.0
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

Versi PHP yang kamu gunakan harus lebih atau sama dengan versi 7.0.0, kemudian kamu juga harus mengaktifkan beberapa ekstensi PHP yang dibutuhkan seperti OpenSSL, PDO, MbString, Tokenizer dan XML.

Jika semua kebutuhan diatas sudah dipenuhi maka kamu sudah bisa memulai membuat project baru Laravel dengan Composer.

Seperti pada dokumentasi resminya, untuk membuat project baru pada Laravel yaitu ada 2 cara. Cara pertama menggunakan Laravel Installer dan cara kedua menggunakan perintah Composer Create Project. Sebetulnya kedua cara tersebut juga sama-sama membutuhkan Composer, hanya saja ketika kamu menggunakan Laravel Installer maka kedepannya kamu akan lebih mudah ketika membuat project baru pada Laravel, karena perintahnya sangat sederhana. Disini saya akan menggunakan kedua cara tersebut agar kamu bisa lebih paham perbedaanya.

Membuat Project Dengan Laravel Installer

Pertama, kamu harus mengunduh Laravel Installer dengan Composer. Buka terminal/command prompt kamu lalu ketik perintah berikut.

composer global require "laravel/installer"

Tunggu hingga proses pengunduhan selesai. Jika berhasil maka hasilnya akan terlihat seperti ini:

Changed current directory to C:/Users/YourName/AppData/Roaming/Composer
Using version ^1.5 for laravel/installer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 11 installs, 0 updates, 0 removals
  - Installing symfony/process (v3.4.3): Loading from cache
  - Installing symfony/filesystem (v3.4.3): Downloading (100%)
  - Installing symfony/polyfill-mbstring (v1.6.0): Loading from cache
  - Installing psr/log (1.0.2): Loading from cache
  - Installing symfony/debug (v3.4.3): Loading from cache
  - Installing symfony/console (v3.4.3): Loading from cache
  - Installing guzzlehttp/promises (v1.3.1): Loading from cache
  - Installing psr/http-message (1.0.1): Loading from cache
  - Installing guzzlehttp/psr7 (1.4.2): Loading from cache
  - Installing guzzlehttp/guzzle (6.3.0): Loading from cache
  - Installing laravel/installer (v1.5.0): Downloading (100%)
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/lock ()
Writing lock file
Generating autoload files

Atau agar lebih yakin kamu bisa menggunakan perintah berikut untuk mengecek apakah Laravel Installer sudah benar-benar terpasang atau belum.

laravel -v

Perintah diatas untuk mengecek versi Laravel Installer yang terpasang di system kamu dan perintah diatas akan menampilkan output seperti berikut.

Laravel Installer 1.5.0

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help  Displays help for a command
  list  Lists commands
  new   Create a new Laravel application.

Jika Laravel Installer belum terpasang silahkan coba kembali cara yang sudah disebtukan diatas atau pastikan Composer kamu sudah dalam keadaan global.

Setelah itu, sekarang kita akan mencoba membuat project baru pada Laravel dengan menggunakan perintah Laravel Installer. 

laravel new [nama_project]

Untuk membuat project baru dengan Laravel Installer, kamu dapat menggunakan perintah diatas dan berikut adalah penjelasannya:

  • laravel adalah perintah disediakan oleh Laravel Installer
  • new adalah perintah untuk membuat project baru Laravel
  • [nama_project] adalah argumen untuk menyesuaikan nama project yang akan kita buat

Sekarang kita akan coba buat project baru pada Laravel dengan nama inventory dan sebelum itu kamu perlu mengarahkan terminal/command prompt kamu ke folder root web server kamu. Misal kalau kamu pake apache dengan XAMPP maka root folder nya adalah C:/xampp/htdocs (C:/ adalah drive tempat kamu menginstal XAMPP) atau kalau kamu menggunakan web server lain maka silahkan cari folder root folder web server tersebut.

Untuk mengarahkan folder pada terminal/command prompt maka gunakan perintah berikut dan sesuaikan dengan lokasi root folder web server kamu.

Jika Menggunakan Command Prompt.

C:
cd xampp\htdocs

Keterangan perintah:

  • C: adalah perintah untuk melakukan perpindahan drive dan “C” adalah nama drivenya.
  • cd adalah perintah untuk melakukan perpindahan direktori (change directory).
  • xampp\htdocs adalah argumen nama folder tujuan untuk dilakukannya perpindahan lokasi direktori. Jadi, artinya folder htdocs berada didalam folder xampp dan tanda “\” adalah sebagai pemisah nama folder tersebut.

Jika menggunakan Bash di Windows.

cd /c/xampp/htdocs

Keterangan perintah:

  • cd adalah perintah untuk melakukan perpindahan direktori (change directory).
  • /c/xampp/htdocs adalah argumen nama folder tujuan untuk dilakukannya perpindahan direktori pada bash. Sama seperti pada Command Prompt, “C” adalah nama drivenya dan xampp/htdocs adalah nama folder tujuannya.

Yang dimaksud dengan “perpindahan” pada perintah diatas bukan berarti memindahkan folder ketempat lain tapi, mengarahkan terminal/command prompt ke folder tersebut agar folder tersebut dapat di-manage oleh terminal/command prompt.

Jika sudah selesai melakukan change directory di terminal/command prompt kamu maka selanjutnya ketik perintah dibawah untuk membuat project baru pada Laravel.

laravel new inventory

Jika nama project lebih dari 1 suku kata maka gunakan tanda “_” atau “-” dibandingkan spasi, jika kamu menggunakan spasi maka akan dianggap argumen lain oleh Laravel Installer dan akan terjadi galat.

Tunggu hingga proses pembuatan project baru selesai. Jika sudah selesai maka akan menampilkan output seperti ini.

Crafting application...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 70 installs, 0 updates, 0 removals
  - Installing symfony/thanks (v1.0.1): Downloading (100%)
  - Installing doctrine/inflector (v1.2.0): Loading from cache
  - Installing doctrine/lexer (v1.0.1): Loading from cache
  - Installing erusev/parsedown (1.6.4): Loading from cache
  - Installing vlucas/phpdotenv (v2.4.0): Loading from cache
  - Installing symfony/css-selector (v3.4.3): Loading from cache
  - Installing tijsverkoyen/css-to-inline-styles (2.2.1): Downloading (100%)
  - Installing symfony/polyfill-mbstring (v1.6.0): Loading from cache
  - Installing symfony/var-dumper (v3.4.3): Loading from cache
  - Installing symfony/routing (v3.4.3): Loading from cache
  - Installing symfony/process (v3.4.3): Loading from cache
  - Installing paragonie/random_compat (v2.0.11): Loading from cache
  - Installing symfony/polyfill-php70 (v1.6.0): Loading from cache
  - Installing symfony/http-foundation (v3.4.3): Loading from cache
  - Installing symfony/event-dispatcher (v3.4.3): Loading from cache
  - Installing psr/log (1.0.2): Loading from cache
  - Installing symfony/debug (v3.4.3): Loading from cache
  - Installing symfony/http-kernel (v3.4.3): Loading from cache
  - Installing symfony/finder (v3.4.3): Loading from cache
  - Installing symfony/console (v3.4.3): Loading from cache
  - Installing egulias/email-validator (2.1.3): Loading from cache
  - Installing swiftmailer/swiftmailer (v6.0.2): Loading from cache
  - Installing ramsey/uuid (3.7.1): Loading from cache
  - Installing psr/simple-cache (1.0.0): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing symfony/translation (v3.4.3): Loading from cache
  - Installing nesbot/carbon (1.22.1): Loading from cache
  - Installing mtdowling/cron-expression (v1.2.1): Loading from cache
  - Installing monolog/monolog (1.23.0): Loading from cache
  - Installing league/flysystem (1.0.41): Loading from cache
  - Installing laravel/framework (v5.5.28): Loading from cache
  - Installing fideloper/proxy (3.3.4): Loading from cache
  - Installing jakub-onderka/php-console-color (0.1): Loading from cache
  - Installing nikic/php-parser (v3.1.3): Loading from cache
  - Installing jakub-onderka/php-console-highlighter (v0.3.2): Loading from cache
  - Installing dnoegel/php-xdg-base-dir (0.1): Loading from cache
  - Installing psy/psysh (v0.8.17): Loading from cache
  - Installing laravel/tinker (v1.0.3): Loading from cache
  - Installing filp/whoops (2.1.14): Loading from cache
  - Installing fzaninotto/faker (v1.7.1): Loading from cache
  - Installing hamcrest/hamcrest-php (v2.0.0): Loading from cache
  - Installing mockery/mockery (1.0): Loading from cache
  - Installing webmozart/assert (1.2.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.2.0): Loading from cache
  - Installing phpunit/php-token-stream (2.0.2): Loading from cache
  - Installing sebastian/version (2.0.1): Loading from cache
  - Installing sebastian/resource-operations (1.0.0): Loading from cache
  - Installing sebastian/recursion-context (3.0.0): Loading from cache
  - Installing sebastian/object-reflector (1.1.1): 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 (3.1.0): Loading from cache
  - Installing sebastian/diff (2.0.1): Loading from cache
  - Installing sebastian/comparator (2.1.2): Downloading (100%)
  - Installing phpunit/php-text-template (1.2.1): Loading from cache
  - Installing doctrine/instantiator (1.0.5): Downloading (100%)
  - Installing phpunit/phpunit-mock-objects (5.0.6): Loading from cache
  - Installing phpunit/php-timer (1.0.9): Loading from cache
  - Installing phpunit/php-file-iterator (1.4.5): Loading from cache
  - Installing theseer/tokenizer (1.1.0): Loading from cache
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
  - Installing phpunit/php-code-coverage (5.3.0): Loading from cache
  - Installing phpspec/prophecy (1.7.3): Loading from cache
  - Installing phar-io/version (1.0.1): Loading from cache
  - Installing phar-io/manifest (1.0.1): Loading from cache
  - Installing myclabs/deep-copy (1.7.0): Loading from cache
  - Installing phpunit/phpunit (6.5.5): Loading from cache
symfony/var-dumper suggests installing ext-intl (To show region name in time zone dump)
symfony/var-dumper suggests installing ext-symfony_debug ()
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/dependency-injection (For loading routes from a service)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
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 ()
egulias/email-validator suggests installing ext-intl (PHP Internationalization Libraries are required to use the SpoofChecking validation)
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 ircmaxell/random-lib (Provides RandomLib for use with the RandomLibAdapter)
ramsey/uuid suggests installing moontoast/math (Provides support for converting UUID to 128-bit integer (in string form).)
ramsey/uuid suggests installing ramsey/uuid-console (A console application for generating UUIDs with ramsey/uuid)
ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.)
symfony/translation suggests installing symfony/config ()
symfony/translation suggests installing symfony/yaml ()
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
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 graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
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 league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
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-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
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)
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.5).)
laravel/framework suggests installing ext-pcntl (Required to use all features of the queue worker.)
laravel/framework suggests installing ext-posix (Required to use all features of the queue worker.)
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 Flysystem caching (~1.0).)
laravel/framework suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (~1.0).)
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 (~3.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 (~3.3).)
laravel/framework suggests installing symfony/psr-http-message-bridge (Required to psr7 bridging features (~1.0).)
psy/psysh suggests installing ext-pcntl (Enabling the PCNTL extension makes PsySH a lot happier :))
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing ext-posix (If you have PCNTL, you'll want the POSIX extension as well.)
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/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.5)
phpunit/phpunit suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^1.1)
Generating optimized autoload files
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
> @php artisan key:generate
Application key [base64:Dm/2GMxkHr3qzUXTkp3le6VOL1mp0uIc84Fa36zylus=] set successfully.
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Package manifest generated successfully.
Application ready! Build something amazing.

Mudah kan untuk membuat project baru pada Laravel? Berikutnya kita akan mencoba membuat project baru pada Laravel dengan perintah Composer create-project.

Membuat Project Dengan Composer create-project

Sekarang kita akan membuat project baru pada Laravel dengan cara lain yaitu dengan menggunakan perintah Composer create-project.

Tidak ada perbedaan sebetulnya dengan cara pertama, cara ini hanya saja kita menggunakan perintah pada Composer.

Untuk membuat project baru pada Laravel gunakan perintah berikut.

composer create-project --prefer-dist laravel/laravel [nama_project]

Keterangan perintah:

  • composer adalah perintah awal pada Composer
  • create-project adalah perintah untuk membuat project baru
  • –prefer-dist adalah opsi untuk memaksa Composer menginstal paket dengan versi dist dibanding versi dev
  • laravel/laravel adalah nama paket yang akan kita instal, dalam hal ini kita akan menginstal Laravel, kan? Maka laravel/laravel adalah nama paket dari Laravel yang dikenali oleh Composer
  • [nama_project] adalah nama folder atau nama project yang akan kita buat. Sama seperti sebelumnya, kamu harus menggunakan tanda “_” atau “-” dibanding spasi jika nama project kamu lebih dari 1 suku kata

Karena nama inventory sudah kita gunakan sebelumnya maka kita akan menggunkan nama inventory-2 dan perintahnya akan seperti berikut.

composer create-project --prefer-dist laravel/laravel inventory-2

Tunggu hingga proses pembuatan project selesai dan akan menampilkan output seperti berikut.

Installing laravel/laravel (v5.5.28)
  - Installing laravel/laravel (v5.5.28): Downloading (100%)
Created project in inventory-2
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 70 installs, 0 updates, 0 removals
  - Installing symfony/thanks (v1.0.1): Loading from cache
  - Installing hamcrest/hamcrest-php (v2.0.0): Loading from cache
  - Installing mockery/mockery (1.0): Loading from cache
  - Installing vlucas/phpdotenv (v2.4.0): Loading from cache
  - Installing symfony/css-selector (v3.4.3): Loading from cache
  - Installing tijsverkoyen/css-to-inline-styles (2.2.1): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.6.0): Loading from cache
  - Installing symfony/var-dumper (v3.4.3): Loading from cache
  - Installing symfony/routing (v3.4.3): Loading from cache
  - Installing symfony/process (v3.4.3): Loading from cache
  - Installing paragonie/random_compat (v2.0.11): Loading from cache
  - Installing symfony/polyfill-php70 (v1.6.0): Loading from cache
  - Installing symfony/http-foundation (v3.4.3): Loading from cache
  - Installing symfony/event-dispatcher (v3.4.3): Loading from cache
  - Installing psr/log (1.0.2): Loading from cache
  - Installing symfony/debug (v3.4.3): Loading from cache
  - Installing symfony/http-kernel (v3.4.3): Loading from cache
  - Installing symfony/finder (v3.4.3): Loading from cache
  - Installing symfony/console (v3.4.3): Loading from cache
  - Installing doctrine/lexer (v1.0.1): Loading from cache
  - Installing egulias/email-validator (2.1.3): Loading from cache
  - Installing swiftmailer/swiftmailer (v6.0.2): Loading from cache
  - Installing ramsey/uuid (3.7.1): Loading from cache
  - Installing psr/simple-cache (1.0.0): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing symfony/translation (v3.4.3): Loading from cache
  - Installing nesbot/carbon (1.22.1): Loading from cache
  - Installing mtdowling/cron-expression (v1.2.1): Loading from cache
  - Installing monolog/monolog (1.23.0): Loading from cache
  - Installing league/flysystem (1.0.41): Loading from cache
  - Installing erusev/parsedown (1.6.4): Loading from cache
  - Installing doctrine/inflector (v1.3.0): Loading from cache
  - Installing laravel/framework (v5.5.28): Loading from cache
  - Installing fideloper/proxy (3.3.4): Loading from cache
  - Installing jakub-onderka/php-console-color (0.1): Loading from cache
  - Installing jakub-onderka/php-console-highlighter (v0.3.2): Loading from cache
  - Installing dnoegel/php-xdg-base-dir (0.1): Loading from cache
  - Installing nikic/php-parser (v3.1.3): Loading from cache
  - Installing psy/psysh (v0.8.17): Loading from cache
  - Installing laravel/tinker (v1.0.3): Loading from cache
  - Installing filp/whoops (2.1.14): Loading from cache
  - Installing fzaninotto/faker (v1.7.1): Loading from cache
  - Installing sebastian/version (2.0.1): Loading from cache
  - Installing sebastian/resource-operations (1.0.0): Loading from cache
  - Installing sebastian/recursion-context (3.0.0): Loading from cache
  - Installing sebastian/object-reflector (1.1.1): 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 (3.1.0): Loading from cache
  - Installing sebastian/diff (2.0.1): Loading from cache
  - Installing sebastian/comparator (2.1.2): Loading from cache
  - Installing doctrine/instantiator (1.1.0): Loading from cache
  - Installing phpunit/php-text-template (1.2.1): Loading from cache
  - Installing phpunit/phpunit-mock-objects (5.0.6): Loading from cache
  - Installing phpunit/php-timer (1.0.9): Loading from cache
  - Installing phpunit/php-file-iterator (1.4.5): Loading from cache
  - Installing theseer/tokenizer (1.1.0): Loading from cache
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
  - Installing phpunit/php-token-stream (2.0.2): Loading from cache
  - Installing phpunit/php-code-coverage (5.3.0): Loading from cache
  - Installing webmozart/assert (1.2.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.2.0): Loading from cache
  - Installing phpspec/prophecy (1.7.3): Loading from cache
  - Installing phar-io/version (1.0.1): Loading from cache
  - Installing phar-io/manifest (1.0.1): Loading from cache
  - Installing myclabs/deep-copy (1.7.0): Loading from cache
  - Installing phpunit/phpunit (6.5.5): Loading from cache
symfony/var-dumper suggests installing ext-intl (To show region name in time zone dump)
symfony/var-dumper suggests installing ext-symfony_debug ()
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/dependency-injection (For loading routes from a service)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
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 ()
egulias/email-validator suggests installing ext-intl (PHP Internationalization Libraries are required to use the SpoofChecking validation)
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 aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
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 graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
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 league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
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-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
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)
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.5).)
laravel/framework suggests installing ext-pcntl (Required to use all features of the queue worker.)
laravel/framework suggests installing ext-posix (Required to use all features of the queue worker.)
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 Flysystem caching (~1.0).)
laravel/framework suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (~1.0).)
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 (~3.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 (~3.3).)
laravel/framework suggests installing symfony/psr-http-message-bridge (Required to psr7 bridging features (~1.0).)
psy/psysh suggests installing ext-pcntl (Enabling the PCNTL extension makes PsySH a lot happier :))
psy/psysh suggests installing ext-posix (If you have PCNTL, you'll want the POSIX extension as well.)
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/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.5)
phpunit/phpunit suggests installing phpunit/php-invoker (^1.1)
phpunit/phpunit suggests installing ext-xdebug (*)
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Package manifest generated successfully.
> @php artisan key:generate
Application key [base64:Fi4qh7WI2YzAhwzCL2M3AKoNCVzmJmwkVD905sWZLL8=] set successfully.

Project yang baru saja kamu buat sudah dapat kamu develop. Berikutnya, kita akan mencoba menjalankan project Laravel tersebut di browser.

Menjalankan Project Laravel

Sekarang, kita akan mencoba menjalankan project Laravel yang baru saja kita buat tadi. Kamu juga bisa menggunakan 2 cara untuk menjalankan project Laravel.

Cara Pertama, menggunakan command-line

Sebelumnya, arahkan terminal/command line kamu ke folder project Laravel yang baru saja kamu buat tadi dengan perintah seperti berikut.

cd inventory

Kemudian ketik perintah berikut.

php artisan serve

Jika berhasil maka akan menampilkan output seperti berikut.

Laravel development server started: <http://127.0.0.1:8000>

Perintah diatas bertujuan untuk menjalankan web server bawaan PHP. Jadi, pada versi 5.4.0 PHP sudah built-in web server dan web server tersebut hanya untuk keperluan development. Selebihnya kamu bisa baca-baca disini.

Sekarang kamu bisa mengakses project Laravel kamu di browser dengan alamat berikut.

http://127.0.0.1:8000

Dan berikut ini adalah welcome page Laravel.

Jika kamu sudah selesai melakukan development pada project Laravel kamu, kamu bisa menekan tombol kombinasi CTRL+C pada terminal/command prompt untuk menghentikan web server PHP.

Mengakses Langsung Pada Localhost

Cara kedua yaitu langsung mengaksesnya dengan cara seperti biasanya yang biasa kamu lakukan mengakses project PHP kamu pada localhost yaitu dengan membuka URL berikut.

http://localhost/inventory/

Hasilnya akan menampilkan seluruh isi dari folder inventory tersebut, ya? Maka kamu perlu mengarahkannya ke folder public. Jadi URL yang benar adalah seperti berikut.

http://localhost/inventory/public/

Dan hasilnya sama seperti cara pertama akan menampilkan welcome page Laravel.

 

Final Words

Pada kesempatan berikutnya kita akan coba membahas tentang Route, Controller, Model dan View pada Laravel. Semoga kita masih diberi kesehatan agar dapat berjumpa lagi pada kesempatan lain dan juga jangan lupa untuk membagikan artikel ini ke teman-teman kamu yang lagi belajar Laravel. Semoga Bermanfaat.

Topik:

Muhamad Nauval Azhar
11 months ago  •  Posted by
Muhamad Nauval Azhar
Junior Programmer

Pecinta Alam (Mbah dukun)

Dapatkan notifikasi untuk setiap artikel baru dan jadilah yang pertama tahu!