Skip to content

Commit

Permalink
update generate env after install via composer
Browse files Browse the repository at this point in the history
  • Loading branch information
naagaraa committed Jun 7, 2021
1 parent 0814093 commit a72ae0a
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 7 deletions.
28 changes: 22 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
# this u have config or change the name folder
# write this config
# config file .env untuk configurasi pada file
# apps/config/database.php
# apps/config/constant.php

# configurasi Path here
APP_DEBUG=true
APP_ENV=local
APP_MAINTENANCE=off

# configurasi Path here
APP_NAME=prosedural-php-native
APP_FOLDER=/prosedural-php-native/
APP_HOST=http://localhost/
APP_URL=http://localhost/prosedural-php-native/

#database config
# configurasi Database here
DB_HOST=localhost
DB_PORT=3306
DB_NAME=
DB_USER=root
DB_PASS=
DB_USERNAME=root
DB_PASSWORD=

# configurasi mailer (on development)
MAIL_DEBUG=true
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME='${APP_NAME}'
Binary file modified README.md
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"scripts": {
"post-create-project-cmd": [
"cp .env.example .env"
"php includes/script/generate.php"
]
},
"minimum-stability": "dev",
Expand Down
1 change: 1 addition & 0 deletions includes/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
41 changes: 41 additions & 0 deletions includes/script/generate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
*------------------------------------------------------------------------------------------------------
* generate env
* @author nagara
*------------------------------------------------------------------------------------------------------
*
* generate folder directory after install via composer
*/


function create_env()
{
/**
* Handle untuk create automation file .env
* untuk create env project sesuai folder project
*/
$path = dirname(__FILE__, 3);

$newpt = str_replace("\\","/", $path);

$dir = explode('/', $newpt);
$new_project = end($dir);

if (file_exists($newpt . '//.env')) {
print("file sudah ada");
// $FileEnvirotmentVariabel = fopen($newpt . '//.env', "w") or die("Unable to open file!");
// $txt = "# config file .env untuk configurasi pada file\n# apps/config/database.php\n# apps/config/constant.php\n\nAPP_DEBUG=true\nAPP_ENV=local\nAPP_MAINTENANCE=off\n\n# configurasi Path here\nAPP_NAME=" . $new_project . "\nAPP_FOLDER=/" . $new_project . "/\nAPP_HOST=http://localhost/\nAPP_URL=http://localhost/" . $new_project . "/\n\n# configurasi Database here\nDB_HOST=localhost\nDB_PORT=3306\nDB_NAME=" . $new_project . "\nDB_USERNAME=root\nDB_PASSWORD=\n\n# configurasi mailer (on development)\nMAIL_DEBUG=true\nMAIL_MAILER=smtp\nMAIL_HOST=mailhog\nMAIL_PORT=1025\nMAIL_USERNAME=null\nMAIL_PASSWORD=null\nMAIL_ENCRYPTION=null\nMAIL_FROM_ADDRESS=null\nMAIL_FROM_NAME='$"."{". "APP_NAME"."}'";

// fwrite($FileEnvirotmentVariabel, $txt);
// fclose($FileEnvirotmentVariabel);
} else {
$FileEnvirotmentVariabel = fopen($newpt . '//.env', "w") or die("Unable to open file!");
$txt = "# config file .env untuk configurasi pada file\n# apps/config/database.php\n# apps/config/constant.php\n\nAPP_DEBUG=true\nAPP_ENV=local\nAPP_MAINTENANCE=off\n\n# configurasi Path here\nAPP_NAME=" . $new_project . "\nAPP_FOLDER=/" . $new_project . "/\nAPP_HOST=http://localhost/\nAPP_URL=http://localhost/" . $new_project . "/\n\n# configurasi Database here\nDB_HOST=localhost\nDB_PORT=3306\nDB_NAME=\nDB_USERNAME=root\nDB_PASSWORD=\n\n# configurasi mailer (on development)\nMAIL_DEBUG=true\nMAIL_MAILER=smtp\nMAIL_HOST=mailhog\nMAIL_PORT=1025\nMAIL_USERNAME=null\nMAIL_PASSWORD=null\nMAIL_ENCRYPTION=null\nMAIL_FROM_ADDRESS=null\nMAIL_FROM_NAME='$"."{". "APP_NAME"."}'";

fwrite($FileEnvirotmentVariabel, $txt);
fclose($FileEnvirotmentVariabel);
}
}

create_env();
10 changes: 10 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
<hr>
<address>Apache/2.4.47 (Win64) OpenSSL/1.1.1k PHP/7.4.18 Server at localhost Port 80</address>
</body></html>
9 changes: 9 additions & 0 deletions storage/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
<hr>
<address>Apache/2.4.47 (Win64) OpenSSL/1.1.1k PHP/7.4.18 Server at localhost Port 80</address>
</body></html>

0 comments on commit a72ae0a

Please sign in to comment.