Laravel CRUD Install Laravel
Learn Laravel CRUD Install Laravel – Laravel adalah framework aplikasi web berbasis bahasa pemrograman PHP. Jika Anda seorang pemula yang ingin mempelajari laravel secara cepat, anda berada di artikel yang tepat. Pada artikel ini berisi cara install Xampp, Composer & Laravel.
Adapun seri belajar CRUD laravel dari artikel ini adalah:
- Install XAMPP, Composer dan Laravel
- Buat Database
- Baca data dari Database
- Buat data dan simpan ke database
- Edit data dan simpan ke database
- Hapus data dari database
Ketika panduan ditulis, saya menggunakan OS Linux (Ubuntu) dan editor kode yang saya gunakan adalah Microsoft Visual Studio Code.
Install XAMPP
Web server lokal saya menggunakan XAMPP. Untuk instalasi dilinux, saya telah membuat artikel yang bisa membacanya disini.
Pada artikel ini saya membuat sebuah folder di dalam folder Document dan menamakannya “Learn Laravel”, di mana nanti projek Laravel akan diinstal di folder ini.
Sekarang masuk ke folder “Learn Laravel”, lalu buka terminal didalamnya.
Install Composer
Saya melakukan instalasi composer di terminal dengan perintah:
sudo apt install composer
Jika composer sudah terinstall, kita bisa mengeceknya dengan perintah “composer
” di terminal. Jika sudah terpasang dengan benar maka akan terlihat seperti berikut :
neon@neon-X450CC:~/Documents/Learn Laravel$ composer ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ / __ `__ / __ / __ / ___/ _ / ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / ____/____/_/ /_/ /_/ .___/____/____/___/_/ /_/ Composer 2.0.9 2021-01-27 16:09:27 Usage: command [options] [arguments] Options: -h, --help Display help for the given command. When no command is given display help for the list command -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 --profile Display timing and memory usage information --no-plugins Whether to disable plugins. -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. --no-cache Prevent use of the cache -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: about Shows the short information about Composer. archive Creates an archive of this composer package. browse [home] Opens the package's repository URL or homepage in your browser. check-platform-reqs Check that platform requirements are satisfied. clear-cache [clearcache|cc] Clears composer's internal package cache. config Sets config options. create-project Creates new project from a package into given directory. depends [why] Shows which packages cause the given package to be installed. diagnose Diagnoses the system to identify common errors. dump-autoload [dumpautoload] Dumps the autoloader. exec Executes a vendored binary/script. fund Discover how to help fund the maintenance of your dependencies. global Allows running commands in the global composer dir ($COMPOSER_HOME). help Display help for a command t Creates a basic composer.json file in current directory. install [i] Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json. licenses Shows information about licenses of dependencies. list List commands outdated Shows a list of installed packages that have updates available, including their latest version. prohibits [why-not] Shows which packages prevent the given package from being installed. remove Removes a package from the require or require-dev. require Adds required packages to your composer.json and installs them. run-script [run] Runs the scripts defined in composer.json. search Searches for packages. show [info] Shows information about packages. status Shows a list of locally modified packages. suggests Shows package suggestions. update [u|upgrade] Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file. validate Validates a composer.json and composer.lock. neon@neon-X450CC:~/Documents/Learn Laravel$
Install Laravel
Sekarang saatnya kita install laravel dengan mendownload paket laravel terlebih dahulu melalui terminal. Pastikan Anda telah terhubung ke internet. Paket laravel yang diunduh tidak besar, sekitar 30MB.
Buat projek laravel dengan nama projek “crud” dan gunakan perintah berikut:
composer create-project --prefer-dist laravel/laravel crud
Tunggu hingga proses download selesai.
neon@neon-X450CC:~/Documents/Learn Laravel$ composer create-project --prefer-dist laravel/laravel crud Creating a "laravel/laravel" project at "./crud" Installing laravel/laravel (v8.6.5) - Installing laravel/laravel (v8.6.5): Extracting archive Created project in /home/neon/Documents/Learn Laravel/crud > @php -r "file_exists('.env') || copy('.env.example', '.env');" Loading composer repositories with package information Updating dependencies Lock file operations: 111 installs, 0 updates, 0 removals - Locking asm89/stack-cors (v2.0.3) - Locking brick/math (0.9.3) - Locking dflydev/dot-access-data (v3.0.1) - Locking doctrine/inflector (2.0.4) - Locking doctrine/instantiator (1.4.0) - Locking doctrine/lexer (1.2.1) - Locking dragonmantank/cron-expression (v3.1.0) - Locking egulias/email-validator (2.1.25) - Locking facade/flare-client-php (1.9.1) - Locking facade/ignition (2.14.1) - Locking facade/ignition-contracts (1.0.2) - Locking fakerphp/faker (v1.16.0) - Locking filp/whoops (2.14.4) - Locking fruitcake/laravel-cors (v2.0.4) - Locking graham-campbell/result-type (v1.0.3) - Locking guzzlehttp/guzzle (7.4.0) - Locking guzzlehttp/promises (1.5.1) - Locking guzzlehttp/psr7 (2.1.0) - Locking hamcrest/hamcrest-php (v2.0.1) - Locking laravel/framework (v8.69.0) - Locking laravel/sail (v1.12.3) - Locking laravel/sanctum (v2.12.1) - Locking laravel/serializable-closure (v1.0.3) - Locking laravel/tinker (v2.6.2) - Locking league/commonmark (2.0.2) - Locking league/config (v1.1.1) - Locking league/flysystem (1.1.5) - Locking league/mime-type-detection (1.8.0) - Locking mockery/mockery (1.4.4) - Locking monolog/monolog (2.3.5) - Locking myclabs/deep-copy (1.10.2) - Locking nesbot/carbon (2.54.0) - Locking nette/schema (v1.2.2) - Locking nette/utils (v3.2.5) - Locking nikic/php-parser (v4.13.1) - Locking nunomaduro/collision (v5.10.0) - Locking opis/closure (3.6.2) - Locking phar-io/manifest (2.0.3) - Locking phar-io/version (3.1.0) - Locking phpdocumentor/reflection-common (2.2.0) - Locking phpdocumentor/reflection-docblock (5.3.0) - Locking phpdocumentor/type-resolver (1.5.1) - Locking phpoption/phpoption (1.8.0) - Locking phpspec/prophecy (1.14.0) - Locking phpunit/php-code-coverage (9.2.8) - Locking phpunit/php-file-iterator (3.0.5) - Locking phpunit/php-invoker (3.1.1) - Locking phpunit/php-text-template (2.0.4) - Locking phpunit/php-timer (5.0.3) - Locking phpunit/phpunit (9.5.10) - Locking psr/container (1.1.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 (2.0.0) - Locking psr/simple-cache (1.0.1) - Locking psy/psysh (v0.10.9) - Locking ralouphie/getall - Locking ramsey/collection (1.2.2) - Locking ramsey/uuid (4.2.3) - Locking sebastian/cli-parser (1.0.1) - Locking sebastian/code-unit (1.0.8) - Locking sebastian/code-unit-reverse-lookup (2.0.3) - Locking sebastian/comparator (4.0.6) - Locking sebastian/complexity (2.0.2) - Locking sebastian/diff (4.0.4) - Locking sebastian/environment (5.1.3) - Locking sebastian/exporter (4.0.3) - Locking sebastian/global-state (5.0.3) - Locking sebastian/lines-of-code (1.0.3) - Locking sebastian/object-enumerator (4.0.4) - Locking sebastian/object-reflector (2.0.4) - Locking sebastian/recursion-context (4.0.4) - Locking sebastian/resource-operations (3.0.3) - Locking sebastian/type (2.3.4) - Locking sebastian/version (3.0.2) - Locking swiftmailer/swiftmailer (v6.3.0) - Locking symfony/console (v5.3.10) - Locking symfony/css-selector (v5.3.4) - Locking symfony/deprecation-contracts (v2.4.0) - Locking symfony/error-handler (v5.3.7) - Locking symfony/event-dispatcher (v5.3.7) - Locking symfony/event-dispatcher-contracts (v2.4.0) - Locking symfony/finder (v5.3.7) - Locking symfony/http-client-contracts (v2.4.0) - Locking symfony/http-foundation (v5.3.10) - Locking symfony/http-kernel (v5.3.10) - Locking symfony/mime (v5.3.8) - Locking symfony/polyfill-ctype (v1.23.0) - Locking symfony/polyfill-iconv (v1.23.0) - Locking symfony/polyfill-intl-grapheme (v1.23.1) - Locking symfony/polyfill-intl-idn (v1.23.0) - Locking symfony/polyfill-intl-normalizer (v1.23.0) - Locking symfony/polyfill-mbstring (v1.23.1) - Locking symfony/polyfill-php72 (v1.23.0) - Locking symfony/polyfill-php73 (v1.23.0) - Locking symfony/polyfill-php80 (v1.23.1) - Locking symfony/polyfill-php81 (v1.23.0) - Locking symfony/process (v5.3.7) - Locking symfony/routing (v5.3.7) - Locking symfony/service-contracts (v2.4.0) - Locking symfony/string (v5.3.10) - Locking symfony/translation (v5.3.10) - Locking symfony/translation-contracts (v2.4.0) - Locking symfony/var-dumper (v5.3.10) - Locking theseer/tokenizer (1.2.1) - Locking tijsverkoyen/css-to-inline-styles (2.2.3) - Locking vlucas/phpdotenv (v5.3.1) - Locking voku/portable-ascii (1.5.6) - Locking webmozart/assert (1.10.0) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 111 installs, 0 updates, 0 removals - Downloading psr/container (1.1.2) - Downloading nesbot/carbon (2.54.0) - Downloading laravel/sail (v1.12.3) - Downloading nikic/php-parser (v4.13.1) - Installing doctrine/inflector (2.0.4): Extracting archive - Installing doctrine/lexer (1.2.1): Extracting archive - Installing symfony/polyfill-ctype (v1.23.0): Extracting archive - Installing webmozart/assert (1.10.0): Extracting archive - Installing dragonmantank/cron-expression (v3.1.0): Extracting archive - Installing symfony/polyfill-php80 (v1.23.1): Extracting archive - Installing symfony/polyfill-mbstring (v1.23.1): Extracting archive - Installing symfony/var-dumper (v5.3.10): Extracting archive - Installing symfony/polyfill-intl-normalizer (v1.23.0): Extracting archive - Installing symfony/polyfill-intl-grapheme (v1.23.1): Extracting archive - Installing symfony/string (v5.3.10): Extracting archive - Installing psr/container (1.1.2): Extracting archive - Installing symfony/service-contracts (v2.4.0): Extracting archive - Installing symfony/polyfill-php73 (v1.23.0): Extracting archive - Installing symfony/deprecation-contracts (v2.4.0): Extracting archive - Installing symfony/console (v5.3.10): Extracting archive - Installing psr/log (2.0.0): Extracting archive - Installing monolog/monolog (2.3.5): Extracting archive - Installing voku/portable-ascii (1.5.6): Extracting archive - Installing phpoption/phpoption (1.8.0): Extracting archive - Installing graham-campbell/result-type (v1.0.3): Extracting archive - Installing vlucas/phpdotenv (v5.3.1): Extracting archive - Installing symfony/css-selector (v5.3.4): Extracting archive - Installing tijsverkoyen/css-to-inline-styles (2.2.3): Extracting archive - Installing symfony/routing (v5.3.7): Extracting archive - Installing symfony/process (v5.3.7): Extracting archive - Installing symfony/polyfill-php72 (v1.23.0): Extracting archive - Installing symfony/polyfill-intl-idn (v1.23.0): Extracting archive - Installing symfony/mime (v5.3.8): Extracting archive - Installing symfony/http-foundation (v5.3.10): Extracting archive - Installing symfony/http-client-contracts (v2.4.0): Extracting archive - Installing psr/event-dispatcher (1.0.0): Extracting archive - Installing symfony/event-dispatcher-contracts (v2.4.0): Extracting archive - Installing symfony/event-dispatcher (v5.3.7): Extracting archive - Installing symfony/error-handler (v5.3.7): Extracting archive - Installing symfony/http-kernel (v5.3.10): Extracting archive - Installing symfony/finder (v5.3.7): Extracting archive - Installing symfony/polyfill-iconv (v1.23.0): Extracting archive - Installing egulias/email-validator (2.1.25): Extracting archive - Installing swiftmailer/swiftmailer (v6.3.0): Extracting archive - Installing symfony/polyfill-php81 (v1.23.0): Extracting archive - Installing ramsey/collection (1.2.2): Extracting archive - Installing brick/math (0.9.3): Extracting archive - Installing ramsey/uuid (4.2.3): Extracting archive - Installing psr/simple-cache (1.0.1): Extracting archive - Installing opis/closure (3.6.2): Extracting archive - Installing symfony/translation-contracts (v2.4.0): Extracting archive - Installing symfony/translation (v5.3.10): Extracting archive - Installing nesbot/carbon (2.54.0): Extracting archive - Installing league/mime-type-detection (1.8.0): Extracting archive - Installing league/flysystem (1.1.5): Extracting archive - Installing nette/utils (v3.2.5): Extracting archive - Installing nette/schema (v1.2.2): Extracting archive - Installing dflydev/dot-access-data (v3.0.1): Extracting archive - Installing league/config (v1.1.1): Extracting archive - Installing league/commonmark (2.0.2): Extracting archive - Installing laravel/serializable-closure (v1.0.3): Extracting archive - Installing laravel/framework (v8.69.0): Extracting archive - Installing facade/ignition-contracts (1.0.2): Extracting archive - Installing facade/flare-client-php (1.9.1): Extracting archive - Installing facade/ignition (2.14.1): Extracting archive - Installing fakerphp/faker (v1.16.0): Extracting archive - Installing asm89/stack-cors (v2.0.3): Extracting archive - Installing fruitcake/laravel-cors (v2.0.4): 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.1.0): Extracting archive - Installing guzzlehttp/promises (1.5.1): Extracting archive - Installing guzzlehttp/guzzle (7.4.0): Extracting archive - Installing laravel/sail (v1.12.3): Extracting archive - Installing laravel/sanctum (v2.12.1): Extracting archive - Installing nikic/php-parser (v4.13.1): Extracting archive - Installing psy/psysh (v0.10.9): Extracting archive - Installing laravel/tinker (v2.6.2): Extracting archive - Installing hamcrest/hamcrest-php (v2.0.1): Extracting archive - Installing mockery/mockery (1.4.4): Extracting archive - Installing filp/whoops (2.14.4): Extracting archive - Installing nunomaduro/collision (v5.10.0): Extracting archive - Installing phpdocumentor/reflection-common (2.2.0): Extracting archive - Installing phpdocumentor/type-resolver (1.5.1): Extracting archive - Installing phpdocumentor/reflection-docblock (5.3.0): Extracting archive - Installing sebastian/version (3.0.2): Extracting archive - Installing sebastian/type (2.3.4): Extracting archive - Installing sebastian/resource-operations (3.0.3): Extracting archive - Installing sebastian/recursion-context (4.0.4): Extracting archive - Installing sebastian/object-reflector (2.0.4): Extracting archive - Installing sebastian/object-enumerator (4.0.4): Extracting archive - Installing sebastian/global-state (5.0.3): Extracting archive - Installing sebastian/exporter (4.0.3): Extracting archive - Installing sebastian/environment (5.1.3): Extracting archive - Installing sebastian/diff (4.0.4): Extracting archive - Installing sebastian/comparator (4.0.6): Extracting archive - Installing sebastian/code-unit (1.0.8): Extracting archive - Installing sebastian/cli-parser (1.0.1): Extracting archive - Installing phpunit/php-timer (5.0.3): Extracting archive - Installing phpunit/php-text-template (2.0.4): Extracting archive - Installing phpunit/php-invoker (3.1.1): Extracting archive - Installing phpunit/php-file-iterator (3.0.5): Extracting archive - Installing theseer/tokenizer (1.2.1): Extracting archive - Installing sebastian/lines-of-code (1.0.3): Extracting archive - Installing sebastian/complexity (2.0.2): Extracting archive - Installing sebastian/code-unit-reverse-lookup (2.0.3): Extracting archive - Installing phpunit/php-code-coverage (9.2.8): Extracting archive - Installing doctrine/instantiator (1.4.0): Extracting archive - Installing phpspec/prophecy (1.14.0): Extracting archive - Installing phar-io/version (3.1.0): Extracting archive - Installing phar-io/manifest (2.0.3): Extracting archive - Installing myclabs/deep-copy (1.10.2): Extracting archive - Installing phpunit/phpunit (9.5.10): Extracting archive 72 package suggestions were added by new dependencies, use `composer suggest` to see details. Generating optimized autoload files > IlluminateFoundationComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Discovered Package: facade/ignition Discovered Package: fruitcake/laravel-cors Discovered Package: laravel/sail Discovered Package: laravel/sanctum Discovered Package: laravel/tinker Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Package manifest generated successfully. 78 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 No publishable resources for tag [laravel-assets]. Publishing complete. > @php artisan key:generate --ansi Application key set successfully.
Sekarang laravel sudah terinstall di komputer. Gunakan perintah php artisan serve
dan laravel akan memberikan alamat web lokal yang akan menampilkan seperti ini:
Selanjutnya kita akan belajar Cara Membuat Database menggunakan Artisan di Laravel.
Semoga bermanfaat.