Skip to content

Instantly share code, notes, and snippets.

@StyxOfDynamite
Created November 1, 2017 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StyxOfDynamite/28cd33be53975edd62676b3166502eb8 to your computer and use it in GitHub Desktop.
Save StyxOfDynamite/28cd33be53975edd62676b3166502eb8 to your computer and use it in GitHub Desktop.
Magento 2 - MacOS Local Setup with Valet
<?php
// Put this file in your ~/.valet/Extensions directory!
/**
* Create a new database on your local machine.
*/
$app->command('db [name]', function ($name) {
if (! $name) {
warning('Please specify a database name');
return;
}
$create_db_command = sprintf("mysql -uroot -e \"create database %s\"", $name);
$create_user_command = sprintf("mysql -uroot -e \"create user '%s'@'localhost' identified by '%s'\"", $name, $name);
$grant_privileges_command = sprintf("mysql -uroot -e \"grant all privileges on %s.* to '%s'@'localhost'\"", $name, $name);
$commands = compact('create_db_command', 'create_user_command', 'grant_privileges_command');
foreach ($commands as $command) {
if ($error = CommandLine::run($command)) {
warning($command);
warning($error);
return;
}
}
info('The database '.$name.' has been created');
})->descriptions('Create a new database');
@StyxOfDynamite
Copy link
Author

  1. Add db.php to ~/.valet/Extensions
  2. Create database valet db magento_2
  3. Unzip magento2 to web root
  4. cd /var/www/magento2 && valet link magento-2
  5. Install magento2
php -d memory_limit=-1 magento setup:install \
--admin-firstname="magento" \
--admin-lastname="admin" \
--admin-email="admin@email.com" \
--admin-user='admin' \
--admin-password="Admin123" \
--base-url="https://magento-2.dev" \
--use-rewrites=1 \
--db-host="localhost" \
--db-user="magento_2" \
--db-name="magento_2" \
--db-password="magento_2" \
--use-secure=1 \
--use-sample-data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment