Skip to content

Commit c78adbc

Browse files
authored
Merge pull request #6 from iajohn/master
Added Global Helper file, Dotenv and Phinx for Database Migration
2 parents 8094cba + 2fdbf2a commit c78adbc

File tree

15 files changed

+1880
-622
lines changed

15 files changed

+1880
-622
lines changed

.env.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# |------------------------------- |
2+
# Basic App Settings ----------- |
3+
# |------------------------------- |
4+
APP_NAME="RawPHP"
5+
APP_DEBUG=true
6+
7+
# |------------------------------- |
8+
# Database Settings ----------- |
9+
# |------------------------------- |
10+
DB_CONNECTION=mysql
11+
DB_HOST=127.0.0.1
12+
DB_NAME=raw-php
13+
DB_USERNAME=raw-php
14+
DB_PASSWORD=secret

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor/*
22
bootstrap/*
33
config/DatabaseConfig.php
4+
.env
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace App\Database\Migrations;
4+
5+
use Illuminate\Database\Capsule\Manager as Capsule;
6+
use Phinx\Migration\AbstractMigration;
7+
8+
class Migration extends AbstractMigration
9+
{
10+
/**
11+
* The name of the database schema to use.
12+
*
13+
* @var string|null
14+
*/
15+
protected $schema;
16+
17+
/**
18+
* The name of the database connection to use.
19+
*
20+
* @var string|null
21+
*/
22+
protected $connection;
23+
24+
/**
25+
* Enables, if supported, wrapping the migration within a transaction.
26+
*
27+
* @var bool
28+
*/
29+
public $withinTransaction = true;
30+
31+
/**
32+
* Get the migration initiated.
33+
*
34+
* @return string|null
35+
*/
36+
public function init()
37+
{
38+
$this->schema = (new Capsule)->schema();
39+
}
40+
41+
/**
42+
* Get the migration connection name.
43+
*
44+
* @return string|null
45+
*/
46+
public function getConnection()
47+
{
48+
return $this->connection;
49+
}
50+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use $useClassName;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class $className extends $baseClassName
7+
{
8+
9+
public function up()
10+
{
11+
$this->schema->create('', function (Blueprint $table) {
12+
$table->increments('id');
13+
$table->timestamps();
14+
});
15+
}
16+
17+
public function down()
18+
{
19+
$this->schema->dropIfExists('');
20+
}
21+
22+
}

0 commit comments

Comments
 (0)