Mengatasi Error Install Laravel via Composer di Mac OS
Mukharom.com – Belum lama ini saya mengalami kesulitan saat melakukan instalasi Laravel untuk melakukan development Website yang sedang saya kerjakan. Ya saya menggunakan framework PHP Laravel untuk membangun website tersebut, tentunya development dilakukan di local komputer yang saya gunakan. Namun setelah update ke Mac OS Catalina ternyata Laravel yang saya install sebelumnya tidak dapat dipanggil, sehingga saya tidak bisa langsung create web baru dengan Laravel tersebut. Akhirnya saya melakukan instalasi ulang Laravel tersebut melalui composer, bagi kalian yang belum memiliki composer bisa menginstallnya dan melihat panduan berikut https://getcomposer.org/.
Namun saya memiliki error ketika menginstallnya, berikut log error saat saya melakukan instalasi Laravel melalui composer tersebut.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Fajars-MacBook-Air:htdocs fajarmukharom$ composer global require laravel/installer Changed current directory to /Users/fajarmukharom/.composer Using version ^3.1 for laravel/installer ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - Installation request for laravel/installer ^3.1 -> satisfiable by laravel/installer[v3.1.0]. - Conclusion: remove symfony/console v3.4.3 - Conclusion: don't install symfony/console v3.4.3 Installation failed, reverting ./composer.json to its original content. |
Langkah selanjutnya saya melakukan update versi PHP pada MacOS saya, update versi PHP tersebut ke versi 7.4 melalui homebrew. Jika kamu belum mengetahui dan belum menginstall homebrew, silakan baca pada artikel saya sebelumnya: Cara Mudah Install Homebrew di Mac OS. Apabila homebrew sudah terinstall, silakan lakukan update versi PHP kalian melalui homebrew dengan perintah berikut pada terminal
brew install [email protected]
Silakan tunggu hingga proses instalasi tersebut selesai, biasanya membutuhkan waktu lama karena homebrew akan melakukan update repository terlebih dahulu. Jika sudah maka langkah selanjutnya saya mengulang instalasi laravel kembali melalui composer, namun masih kembali error yang sama. Laravel belum dapat terinstall di Mac OS yang saya gunakan, hingga akhirnya saya melakukan pencarian dan menemukan alternatif lainnya.
Solusi Instalasi Laravel: Install via CGR
Karena kegagalan yang terus saya alami ketika menggunakan composer untuk menginstall Laravel, akhirnya saya menemukan alternatif lain yakni menggunakan CGR. Cgr menyediakan depedensi PHP seperti salah satunya Laravel, yang fungsinya mirip seperti composer yang detailnya kamu dapat lihat pada halaman https://github.com/consolidation/cgr. Untuk instalasinya pun sangat mudah, pastikan kamu sudah menginstall composer sebelumnya ya
Instalasi CGR
Untuk melakukan instalasi CGR, silakan jalankan perintah berikut melalui terminal Mac OS kamu
composer global require consolidation/cgr
Berikut log instalasi CGR yang saya lakukan dan berhasil di Mac Os milik saya
1 2 3 4 5 6 7 8 9 10 |
Fajars-MacBook-Air:htdocs fajarmukharom$ composer global require consolidation/cgr Changed current directory to /Users/fajarmukharom/.composer Using version ^2.0 for consolidation/cgr ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Installing consolidation/cgr (2.0.5): Downloading (100%) Writing lock file Generating autoload files |
Instalasi Laravel via CGR
Setelah berhasil menginstal CGR melalui composer, langkah selanjutnya adalah melakukan instalasi Laravel melalui CGR tersebut. Untuk melakukan instalasi laravel, silakan ketikkan perintah berikut pada terminal
cgr laravel/installer
Tunggu hingga proses instalasi laravel selesai dan tentunya berhasil. Alhamdulillah proses instalasi yang saya lakukan dapat berjalan dengan lancar dan berhasil, berikut log instalasi yang saya lakukan di Mac OS milik saya
1 2 3 4 5 6 7 8 9 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 |
Fajars-MacBook-Air:learn fajarmukharom$ cgr laravel/installer >> Running: composer '--working-dir=/Users/fajarmukharom/.composer/global/laravel/installer' require 'laravel/installer' Using version ^3.1 for laravel/installer ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 20 installs, 0 updates, 0 removals - Installing symfony/polyfill-php80 (v1.17.0): Loading from cache - Installing symfony/process (v5.1.0): Loading from cache - Installing symfony/polyfill-ctype (v1.17.0): Loading from cache - Installing symfony/filesystem (v5.1.0): Loading from cache - Installing symfony/polyfill-mbstring (v1.17.0): Loading from cache - Installing symfony/polyfill-intl-normalizer (v1.17.0): Loading from cache - Installing symfony/polyfill-intl-grapheme (v1.17.0): Loading from cache - Installing symfony/string (v5.1.0): Loading from cache - Installing psr/container (1.0.0): Loading from cache - Installing symfony/service-contracts (v2.1.2): Loading from cache - Installing symfony/polyfill-php73 (v1.17.0): Loading from cache - Installing symfony/console (v5.1.0): Loading from cache - Installing ralouphie/getallheaders (3.0.3): Loading from cache - Installing psr/http-message (1.0.1): Loading from cache - Installing guzzlehttp/psr7 (1.6.1): Loading from cache - Installing guzzlehttp/promises (v1.3.1): Loading from cache - Installing symfony/polyfill-php72 (v1.17.0): Loading from cache - Installing symfony/polyfill-intl-idn (v1.17.0): Loading from cache - Installing guzzlehttp/guzzle (6.5.4): Loading from cache - Installing laravel/installer (v3.1.0): Downloading (100%) Skipped installation of bin bin/laravel for package laravel/installer: name conflicts with an existing file symfony/service-contracts suggests installing symfony/service-implementation () symfony/console suggests installing symfony/event-dispatcher () symfony/console suggests installing symfony/lock () symfony/console suggests installing psr/log (For using the console logger) guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses) guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware) Writing lock file Generating autoload files |
Membuat Project Baru Laravel
Setelah Laravel berhasil diinstall, kamu dapat membuat project folder baru untuk melakukan development website kamu. Untuk membuat project baru, silakan pindah terlebih dahulu ke directory yang kamu inginkan dengan perintah cd. Kemudian silakan jalankan perintah berikut untuk membuat project baru
laravel new namaproject
Kamu dapat memanggil perintah laravel kapan saja, dan membuat project baru dengan nama yang kamu inginkan. Berikut log proses pembuatan project yang saya lakukan tersebut
1 2 3 4 5 6 7 8 9 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
Fajars-MacBook-Air:learn fajarmukharom$ laravel new omtravel Crafting application... Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 97 installs, 0 updates, 0 removals - Installing doctrine/inflector (2.0.3): Loading from cache - Installing doctrine/lexer (1.2.1): Loading from cache - Installing dragonmantank/cron-expression (v2.3.0): Loading from cache - Installing voku/portable-ascii (1.5.1): Loading from cache - Installing symfony/polyfill-ctype (v1.17.0): Loading from cache - Installing phpoption/phpoption (1.7.3): Loading from cache - Installing vlucas/phpdotenv (v4.1.6): Loading from cache - Installing symfony/css-selector (v5.1.0): Loading from cache - Installing tijsverkoyen/css-to-inline-styles (2.2.2): Loading from cache - Installing symfony/polyfill-php80 (v1.17.0): Loading from cache - Installing symfony/polyfill-mbstring (v1.17.0): Loading from cache - Installing symfony/var-dumper (v5.1.0): Loading from cache - Installing symfony/deprecation-contracts (v2.1.2): Loading from cache - Installing symfony/routing (v5.1.0): Loading from cache - Installing symfony/process (v5.1.0): Loading from cache - Installing symfony/polyfill-php73 (v1.17.0): Loading from cache - Installing symfony/polyfill-php72 (v1.17.0): Loading from cache - Installing symfony/polyfill-intl-idn (v1.17.0): Loading from cache - Installing symfony/mime (v5.1.0): Loading from cache - Installing symfony/http-foundation (v5.1.0): Loading from cache - Installing psr/event-dispatcher (1.0.0): Loading from cache - Installing symfony/event-dispatcher-contracts (v2.1.2): Loading from cache - Installing symfony/event-dispatcher (v5.1.0): Loading from cache - Installing psr/log (1.1.3): Loading from cache - Installing symfony/error-handler (v5.1.0): Loading from cache - Installing symfony/http-kernel (v5.1.0): Loading from cache - Installing symfony/finder (v5.1.0): Loading from cache - Installing symfony/polyfill-intl-normalizer (v1.17.0): Loading from cache - Installing symfony/polyfill-intl-grapheme (v1.17.0): Loading from cache - Installing symfony/string (v5.1.0): Loading from cache - Installing psr/container (1.0.0): Loading from cache - Installing symfony/service-contracts (v2.1.2): Loading from cache - Installing symfony/console (v5.1.0): Loading from cache - Installing symfony/polyfill-iconv (v1.17.0): Loading from cache - Installing egulias/email-validator (2.1.17): Loading from cache - Installing swiftmailer/swiftmailer (v6.2.3): Loading from cache - Installing ramsey/collection (1.0.1): Loading from cache - Installing brick/math (0.8.15): Loading from cache - Installing ramsey/uuid (4.0.1): Loading from cache - Installing psr/simple-cache (1.0.1): Loading from cache - Installing opis/closure (3.5.3): Loading from cache - Installing symfony/translation-contracts (v2.1.2): Loading from cache - Installing symfony/translation (v5.1.0): Loading from cache - Installing nesbot/carbon (2.35.0): Loading from cache - Installing monolog/monolog (2.1.0): Loading from cache - Installing league/flysystem (1.0.69): Loading from cache - Installing league/commonmark (1.4.3): Loading from cache - Installing laravel/framework (v7.14.1): Loading from cache - Installing fideloper/proxy (4.3.0): Loading from cache - Installing asm89/stack-cors (1.3.0): Loading from cache - Installing fruitcake/laravel-cors (v1.0.6): Loading from cache - Installing ralouphie/getallheaders (3.0.3): Loading from cache - Installing psr/http-message (1.0.1): Loading from cache - Installing guzzlehttp/psr7 (1.6.1): Loading from cache - Installing guzzlehttp/promises (v1.3.1): Loading from cache - Installing guzzlehttp/guzzle (6.5.4): Loading from cache - Installing nikic/php-parser (v4.5.0): Loading from cache - Installing dnoegel/php-xdg-base-dir (v0.1.1): Loading from cache - Installing psy/psysh (v0.10.4): Loading from cache - Installing laravel/tinker (v2.4.0): Loading from cache - Installing scrivo/highlight.php (v9.18.1.1): Loading from cache - Installing filp/whoops (2.7.2): Loading from cache - Installing facade/ignition-contracts (1.0.0): Loading from cache - Installing facade/flare-client-php (1.3.2): Loading from cache - Installing facade/ignition (2.0.6): Loading from cache - Installing fzaninotto/faker (v1.9.1): Loading from cache - Installing hamcrest/hamcrest-php (v2.0.0): Loading from cache - Installing mockery/mockery (1.4.0): Loading from cache - Installing nunomaduro/collision (v4.2.0): Loading from cache - Installing webmozart/assert (1.8.0): Loading from cache - Installing phpdocumentor/reflection-common (2.1.0): Loading from cache - Installing phpdocumentor/type-resolver (1.1.0): Loading from cache - Installing phpdocumentor/reflection-docblock (5.1.0): Loading from cache - Installing phpunit/php-token-stream (3.1.1): Loading from cache - Installing sebastian/version (2.0.1): Loading from cache - Installing sebastian/type (1.1.3): Loading from cache - Installing sebastian/resource-operations (2.0.1): 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 (3.0.0): Loading from cache - Installing sebastian/exporter (3.1.2): Loading from cache - Installing sebastian/environment (4.2.3): 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.2): 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.3): Loading from cache - Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache - Installing phpunit/php-code-coverage (7.0.10): Loading from cache - Installing doctrine/instantiator (1.3.1): Loading from cache - Installing phpspec/prophecy (v1.10.3): 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.5): Loading from cache - Installing phpunit/phpunit (8.5.5): Loading from cache Package manifest generated successfully. Application ready! Build something amazing. |
Laravel akan menginstall paket atau dependensi yang dibutuhkan untuk project tersebut, dan melakukan load kedalam folder project yang kamu buat. Setelah proses selesai maka project dapat dilanjut dan proses development website pun dapat dilakukan. Untuk menjalankan project laravel tersebut, silakan masuk ke direktory tempat menyimpan project tersebut dengan perintah cd. Kemudian silakan jalankan perintah berikut
php artisan serve
Secara default project tersebut dapat diakses pada halaman url http://127.0.0.1:8000, silakan lakukan akses pada internet browser favorit kamu.
Bagaimana, mudah bukan melakukan instalasi Laravel menggunakan CGR? Jika Laravel sudah terinstall, maka kamu bisa membuat beberapa project di laptop kamu untuk melakukan development sebuath website berbasis PHP. Apabila kamu memiliki kendala, jangan ragu untuk berdiskusi pada kolom komentar.
Have a good day!