Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

NEW: More helpful message for 'sake dev/build' on new envs.

This change alters the no-db message on cli execution to give a bit more of a helpful set-up instruction.
The main motivation for this is so that composer can be set to run dev/build on post-install and post-update.

With that feature added, this will ensure that users installing with composer create-project won't be left
in the dark.

An improvement on this would be a shell script that interactively asked for details to populate this file
with, but one step at a time.
  • Loading branch information...
commit f1e567eb933ac68856c6457462125c6ef3ebc467 1 parent a29c51d
@sminnee sminnee authored
Showing with 35 additions and 2 deletions.
  1. +1 −1  admin/_config.php
  2. +34 −1 cli-script.php
View
2  admin/_config.php
@@ -6,7 +6,7 @@
'mode' => 'none', // initialized through LeftAndMain.EditFor.js logic
'body_class' => 'typography',
- 'document_base_url' => Director::absoluteBaseURL(),
+ 'document_base_url' => isset($_SERVER['HTTP_HOST']) ? Director::absoluteBaseURL() : null,
'cleanup_callback' => "sapphiremce_cleanup",
View
35 cli-script.php
@@ -68,10 +68,43 @@
// We don't have a session in cli-script, but this prevents errors
$_SESSION = null;
-// Connect to database
require_once("model/DB.php");
+
+
+// Connect to database
+if(!isset($databaseConfig) || !isset($databaseConfig['database']) || !$databaseConfig['database']) {
+ echo "\nPlease configure your database connection details. You can do this by creating a file
+called _ss_environment.php in either of the following locations:\n\n";
+ echo " - " . BASE_PATH ."_ss_environment.php\n - " . dirname(BASE_PATH) . "_ss_environment.php\n\n";
+ echo <<<ENVCONTENT
+
+Put the following content into this file:
+--------------------------------------------------
+<?php
+
+/* Change this from 'dev' to 'live' for a production environment. */
+define('SS_ENVIRONMENT_TYPE', 'dev');
+
+/* This defines a default database user */
+define('SS_DATABASE_SERVER', 'localhost');
+define('SS_DATABASE_USERNAME', '<user>');
+define('SS_DATABASE_PASSWORD', '<password>');
+define('SS_DATABASE_NAME', '<database>');
+--------------------------------------------------
+
+Once you have done that, run 'composer install' or './framework/sake dev/build' to create
+an empty database.
+
+For more information, please read this page in our docs:
+http://doc.silverstripe.org/framework/en/topics/environment-management
+
+
+ENVCONTENT;
+ exit(1);
+}
DB::connect($databaseConfig);
+
// Get the request URL from the querystring arguments
$url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : null;
if(!$url) {
Please sign in to comment.
Something went wrong with that request. Please try again.