1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <project name =" Laravel Project" default =" welcome" basedir =" ../" description =" Laravel Project Build Targets" >
3
+
4
+ <target name =" welcome" >
5
+ <echo message =" Hello, welcome to ${ phing.project.name } !" />
6
+
7
+ <echo message =" There are 2 options 'install' and 'update'" />
8
+ </target >
9
+
10
+
11
+ <target name =" update" >
12
+
13
+ <propertyprompt
14
+ propertyName=" env"
15
+ promptText=" What is your Laravel environment name?"
16
+ />
17
+
18
+ <if >
19
+ <isfalse value =" ${ env } " />
20
+ <then >
21
+ <fail message =" Invalid environment name!" />
22
+ </then >
23
+ </if >
24
+
25
+ <!-- git -->
26
+ <echo message =" Pulling from repository..." />
27
+
28
+ <echo message =" Done." />
29
+ <!-- composer -->
30
+ <echo message =" Checking packages..." />
31
+ <exec
32
+ command=" composer update"
33
+ passthru=" true"
34
+ />
35
+ <echo message =" Done." />
36
+
37
+ <!-- migrations -->
38
+ <echo message =" Running migrations..." />
39
+ <exec
40
+ command=" php artisan migrate --env-${ env } "
41
+ passthru=" true"
42
+ />
43
+ <echo message =" Done." />
44
+
45
+ </target >
46
+
47
+
48
+ <target name =" install" >
49
+
50
+ <echo message =" Before installing you must have created a database, and have the connection details ready. You must also have composer installed." />
51
+
52
+ <propertyprompt
53
+ propertyName=" env.name"
54
+ promptText=" What is your Laravel environment name?"
55
+ />
56
+ <propertyprompt
57
+ propertyName=" env.host"
58
+ promptText=" And the host name you want to use?"
59
+ />
60
+ <echo message =" Database settings..." />
61
+ <propertyprompt
62
+ propertyName=" db.host"
63
+ promptText=" Host:"
64
+ />
65
+ <propertyprompt
66
+ propertyName=" db.name"
67
+ promptText=" Database name:"
68
+ />
69
+ <propertyprompt
70
+ propertyName=" db.user"
71
+ promptText=" Username:"
72
+ />
73
+ <propertyprompt
74
+ propertyName=" db.pass"
75
+ promptText=" Password:"
76
+ />
77
+
78
+ <if >
79
+ <isfalse value =" ${ env.name } " />
80
+ <then >
81
+ <fail message =" Invalid environment name!" />
82
+ </then >
83
+ </if >
84
+
85
+ <if >
86
+ <isfalse value =" ${ env.host } " />
87
+ <then >
88
+ <fail message =" Invalid host name!" />
89
+ </then >
90
+ </if >
91
+
92
+ <!-- configure db -->
93
+ <echo message =" Configuring db..." />
94
+ <mkdir dir =" app/config/${ env.name } " />
95
+ <delete file =" app/config/${ env.name } /database.php" failonerror =" false" />
96
+ <copy file =" build/database.txt" tofile =" app/config/${ env.name } /database.php" overwrite =" true" >
97
+ <filterchain >
98
+ <replaceregexp >
99
+ <regexp pattern =" #DB_HOST#" replace =" ${ db.host } " ignoreCase =" false" />
100
+ <regexp pattern =" #DB_NAME#" replace =" ${ db.name } " ignoreCase =" false" />
101
+ <regexp pattern =" #DB_USER#" replace =" ${ db.user } " ignoreCase =" false" />
102
+ <regexp pattern =" #DB_PASS#" replace =" ${ db.pass } " ignoreCase =" false" />
103
+ </replaceregexp >
104
+ </filterchain >
105
+ </copy >
106
+ <echo message =" Done." />
107
+
108
+ <echo message =" Writing environment..." />
109
+ <copy file =" bootstrap/start.php" tofile =" bootstrap/start-tmp.php" overwrite =" true" >
110
+ <filterchain >
111
+ <replaceregexp >
112
+ <regexp pattern =" detectEnvironment\(array\(" replace =" detectEnvironment(
113
+ array('${ env.name } ' => array('${ env.host } ')," />
114
+ </replaceregexp >
115
+ </filterchain >
116
+ </copy >
117
+ <delete file =" bootstrap/start.php" failonerror =" false" />
118
+ <copy file =" bootstrap/start-tmp.php" tofile =" bootstrap/start.php" overwrite =" true" />
119
+ <echo message =" Done." />
120
+
121
+ <!-- amend .gitignore -->
122
+ <append destFile =" .gitignore" text =" ${ line.separator } app/config/${ env.name } " />
123
+
124
+ <!-- composer -->
125
+ <echo message =" Checking packages..." />
126
+ <exec
127
+ command=" composer update"
128
+ passthru=" true"
129
+ />
130
+ <echo message =" Done." />
131
+
132
+ <!-- migrations -->
133
+ <echo message =" Running db migrations..." />
134
+ <exec
135
+ command=" php artisan migrate --env-${ env } "
136
+ passthru=" true"
137
+ />
138
+ <echo message =" Done." />
139
+
140
+ </target >
141
+
142
+
143
+ </project >
0 commit comments