Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
hhit
config-generator
Commits
a63ae050
Commit
a63ae050
authored
Mar 02, 2021
by
Hendrik Heneke
Browse files
Move binary code to file in src.
parent
0c3008e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
42 deletions
+44
-42
bin/cfgen
bin/cfgen
+1
-42
src/cfgen.php
src/cfgen.php
+43
-0
No files found.
bin/cfgen
View file @
a63ae050
#!/usr/bin/env php
<?php
use
HHIT\ConfigGenerator\Command\GenerateConfigsCommand
;
use
Symfony\Component\Console\Application
;
use
Symfony\Component\Console\Input\ArgvInput
;
use
Symfony\Component\Console\Output\ConsoleOutput
;
if
(
!
in_array
(
PHP_SAPI
,
[
'cli'
,
'phpdbg'
,
'embed'
],
true
))
{
echo
'Warning: The console should be invoked via the CLI version of PHP, not the '
.
PHP_SAPI
.
' SAPI'
.
PHP_EOL
;
}
set_time_limit
(
0
);
$candidates
=
[
dirname
(
__DIR__
)
.
'/../../autoload.php'
=>
dirname
(
__DIR__
)
.
'/../../../'
,
dirname
(
__DIR__
)
.
'/vendor/autoload.php'
=>
dirname
(
__DIR__
)
];
$autoloaderPath
=
null
;
$projectDir
=
null
;
foreach
(
$candidates
as
$autoloaderPathCandidate
=>
$projectDirCandidate
)
{
if
(
file_exists
(
$autoloaderPathCandidate
))
{
$autoloaderPath
=
$autoloaderPathCandidate
;
$projectDir
=
$projectDirCandidate
;
break
;
}
}
if
(
null
===
$autoloaderPath
)
{
throw
new
RuntimeException
(
'Unable to locate autoload.php file.'
);
}
require_once
$autoloaderPath
;
unset
(
$candidates
,
$autoloaderPathCandidate
,
$pojectDirCandidate
);
$application
=
new
Application
(
'Configuration Generator'
);
$application
->
add
(
new
GenerateConfigsCommand
(
$projectDir
));
$input
=
new
ArgvInput
();
if
(
null
!==
$env
=
$input
->
getParameterOption
([
'--env'
,
'-e'
],
'dev'
,
true
))
{
putenv
(
'APP_ENV='
.
$_SERVER
[
'APP_ENV'
]
=
$_ENV
[
'APP_ENV'
]
=
$env
);
}
$output
=
new
ConsoleOutput
();
$application
->
run
(
$input
,
$output
);
require_once
__DIR__
.
'/../src/cfgen.php'
;
src/cfgen.php
0 → 100644
View file @
a63ae050
<?php
use
HHIT\ConfigGenerator\Command\GenerateConfigsCommand
;
use
Symfony\Component\Console\Application
;
use
Symfony\Component\Console\Input\ArgvInput
;
use
Symfony\Component\Console\Output\ConsoleOutput
;
if
(
!
in_array
(
PHP_SAPI
,
[
'cli'
,
'phpdbg'
,
'embed'
],
true
))
{
echo
'Warning: The console should be invoked via the CLI version of PHP, not the '
.
PHP_SAPI
.
' SAPI'
.
PHP_EOL
;
}
set_time_limit
(
0
);
$candidates
=
[
dirname
(
__DIR__
)
.
'/../../autoload.php'
=>
dirname
(
__DIR__
)
.
'/../../../'
,
dirname
(
__DIR__
)
.
'/vendor/autoload.php'
=>
dirname
(
__DIR__
)
];
$autoloaderPath
=
null
;
$projectDir
=
null
;
foreach
(
$candidates
as
$autoloaderPathCandidate
=>
$projectDirCandidate
)
{
if
(
file_exists
(
$autoloaderPathCandidate
))
{
$autoloaderPath
=
$autoloaderPathCandidate
;
$projectDir
=
$projectDirCandidate
;
break
;
}
}
if
(
null
===
$autoloaderPath
)
{
throw
new
RuntimeException
(
'Unable to locate autoload.php file.'
);
}
require_once
$autoloaderPath
;
unset
(
$candidates
,
$autoloaderPathCandidate
,
$pojectDirCandidate
);
$application
=
new
Application
(
'Configuration Generator'
);
$application
->
add
(
new
GenerateConfigsCommand
(
$projectDir
));
$input
=
new
ArgvInput
();
if
(
null
!==
$env
=
$input
->
getParameterOption
([
'--env'
,
'-e'
],
'dev'
,
true
))
{
putenv
(
'APP_ENV='
.
$_SERVER
[
'APP_ENV'
]
=
$_ENV
[
'APP_ENV'
]
=
$env
);
}
$output
=
new
ConsoleOutput
();
$application
->
run
(
$input
,
$output
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment