Next article: PHP generates configuration files based on command line parameters
ghostinit.php
<?PHPclassghostinit{Static $v= ' Ghost version is 1.1 '; Static functioninit () {Echo"Pls input project name?".Php_eol; $projName=fgets(STDIN); Echo"Pls input author?".Php_eol; $author=fgets(STDIN); EchoSelf::buildconfig ([' proj ' =$projName, ' Author ' =$author ] ); } Static functionBuildconfig ($info ){ return file_put_contents(GETCWD() . '/go.json ', Json_encode ($info) ) . ' bytes has written, '. ' config file has created '.Php_eol; } Static functionShow () {$conf= Json_decode (file_get_contents(GETCWD() . '/go.json ' ) ); foreach($conf as $k=$v ){ Echo $k. ‘:‘ .$v; } } Static functionGetConfig ($conf ){ $STD=NewStdClass (); foreach($conf as $k=$v ){ $STD-$k=$v; } return $STD; } Static function__callstatic ($m,$args ){ Echo' Error function '; } }?>
PHP command line build and read configuration file