Skip to content

Commit 8559325

Browse files
author
Tortue Torche
committed
The '--environment' command line option is renamed to '--assets-env'.
Because there was some conflicts with the Laravel command line option ' --env'. And 'larasset-environment' command line option is renamed to '--larasset-env'. See #6 for more information.
1 parent b3c1419 commit 8559325

File tree

4 files changed

+52
-15
lines changed

4 files changed

+52
-15
lines changed

README.md

+18-5
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,18 @@ Installation
4949
composer require efficiently/larasset:dev-master
5050
```
5151

52-
3. Turn on your application debug mode, in your `app/config/app.php` file:
52+
3. Turn on your application debug mode, create or edit the `app/config/local/app.php` file:
5353

5454
```php
55+
<?php
56+
57+
return [
5558
'debug' => true,
59+
// Others config options....
60+
];
5661
```
5762

58-
Note: It is strongly recommended that you turn off error detail in a production environment.
63+
Note: It is strongly recommended that you turn off error detail in your production environment.
5964

6065
4. Add these two services providers to `app/config/app.php`:
6166

@@ -97,7 +102,7 @@ Run:
97102

98103
php artisan larasset:serve
99104

100-
NOTICE: You should use it **only** in a development environment
105+
NOTICE: You should use it **only** in a development/local environment
101106

102107

103108
Precompiling assets (Manifest usage)
@@ -117,11 +122,19 @@ Development VS Production mode
117122
By default Larasset is running in _development_ mode. That means that it will
118123
recompile (server) any changed asset on demand. Also it's not compressing
119124
JavaScript and/or Stylesheets in development mode. To run Larraset's server and
120-
precompiler in production-ready mode, use `--environment production` command line
125+
precompiler in production-ready mode, use `--assets-env production` command line
121126
option, like so:
122127

123-
php artisan larasset:precompile --environment production
128+
php artisan larasset:precompile --assets-env production
129+
130+
131+
Changelog
132+
---------
124133

134+
### 0.9.6-dev
135+
* **Breaking changes:**
136+
The `--environment` command line option is renamed to `--assets-env`. Because there was some conflicts with the Laravel command line option `--env`. And `larasset-environment` command line option is renamed to `--larasset-env`.
137+
See issue [#6](https://github.com/efficiently/larasset/issues/6) for more information.
125138

126139
Credits
127140
-------

src/Efficiently/Larasset/Commands/PrecompileAssetsCommand.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ public function fire()
4141
{
4242
parent::fire();
4343

44-
$environment = $this->option('environment');
44+
if ($this->option('environment')) {
45+
# TODO: Remove the DEPRECATED stuff in the next minor version (0.10.0 or 1.0.0)
46+
$this->comment("WARN: The '--environment' option is DEPRECATED, use '--assets-env' option instead please.");
47+
$assetsEnv = $this->option('environment');
48+
} else {
49+
$assetsEnv = $this->option('assets-env');
50+
}
51+
4552
$packagePath = $this->packagePath();
4653

4754
$searchPaths = array_map(
@@ -58,7 +65,7 @@ function ($path) {
5865
Config::get('larasset::precompile', [])
5966
);
6067
putenv('LARASSET_PRECOMPILE='.implode('|', $precompileFiles));
61-
putenv('LARASSET_ENV='.$environment);
68+
putenv('LARASSET_ENV='.$assetsEnv);
6269
putenv('LARASSET_COMMAND=precompile');
6370
putenv('LARASSET_PREFIX='.Config::get('larasset::prefix'));
6471
$assetsPrecompileCommand = "larasset";
@@ -90,7 +97,8 @@ protected function getArguments()
9097
protected function getOptions()
9198
{
9299
return [
93-
['environment', null, InputOption::VALUE_OPTIONAL, 'Specifies the environment to run this precompilation under.', 'development'],
100+
['assets-env', null, InputOption::VALUE_OPTIONAL, 'Specifies the assets environment to run this precompilation under.', 'development'],
101+
['environment', null, InputOption::VALUE_OPTIONAL, "DEPRECATED: Use '--assets-env' option instead."],
94102

95103
];
96104
}

src/Efficiently/Larasset/Commands/ServeAssetsCommand.php

+10-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ public function fire()
4343

4444
$serverHost = $this->option('host');
4545
$serverPort = $this->option('port');
46-
$serverEnvironment = $this->option('environment');
46+
if ($this->option('environment')) {
47+
# TODO: Remove the DEPRECATED stuff in the next minor version (0.10.0 or 1.0.0)
48+
$this->comment("WARN: The '--environment' option is DEPRECATED, use '--assets-env' option instead please.");
49+
$serverEnv = $this->option('environment');
50+
} else {
51+
$serverEnv = $this->option('assets-env');
52+
}
4753

4854
$serverOptions = "--port=".$serverPort." --host=".$serverHost;
4955
$packagePath = $this->packagePath();
@@ -56,7 +62,7 @@ function ($path) {
5662
);
5763
putenv('LARASSET_PATH='.implode('|', $searchPaths));
5864
putenv('LARASSET_PREFIX='.Config::get('larasset::prefix'));
59-
putenv('LARASSET_ENV='.$serverEnvironment);
65+
putenv('LARASSET_ENV='.$serverEnv);
6066
putenv('LARASSET_COMMAND=server');
6167
$assetsServerCommand = "larasset ".$serverOptions;
6268

@@ -86,7 +92,8 @@ protected function getOptions()
8692
return [
8793
['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the asset files on.', "localhost"],
8894
['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the asset files on.', 3000],
89-
['environment', null, InputOption::VALUE_OPTIONAL, 'Specifies the environment to run this server under (test/development/production).', 'development'],
95+
['assets-env', null, InputOption::VALUE_OPTIONAL, 'Specifies the assets environment to run this server under (test/development/production).', 'development'],
96+
['environment', null, InputOption::VALUE_OPTIONAL, "DEPRECATED: Use '--assets-env' option instead."],
9097
];
9198
}
9299
}

src/Efficiently/Larasset/Commands/ServerCommand.php

+13-4
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,27 @@ public function fire()
4141

4242
$serverHost = $this->option('host');
4343
$serverPort = $this->option('port');
44+
$serverEnv = $this->option('env');
4445
$assetsServerHost = $this->option('larasset-host');
4546
$assetsServerPort = $this->option('larasset-port');
46-
$assetsServerEnvironment = $this->option('larasset-environment');
47+
if ($this->option('larasset-environment')) {
48+
# TODO: Remove the DEPRECATED stuff in the next minor version (0.10.0 or 1.0.0)
49+
$this->comment("WARN: The '--larasset-environment' option is DEPRECATED, use '--larasset-env' option instead please.");
50+
$assetsServerEnv = $this->option('larasset-environment');
51+
} else {
52+
$assetsServerEnv = $this->option('larasset-env');
53+
}
4754

4855
// Run assets server in a background process
49-
$command = "php artisan larasset:serve --port=".$assetsServerPort." --host=".$assetsServerHost." --environment=".$assetsServerEnvironment;
56+
$command = "php artisan larasset:serve --port=".$assetsServerPort." --host=".$assetsServerHost." --assets-env=".$assetsServerEnv;
5057
$this->info("Start the assets server...");
5158

5259
$serverLogsPath = $this->normalizePath(storage_path('logs/larasset_server.log'));
5360
$this->line('Assets server logs are stored in "'.$serverLogsPath.'"');
5461
$this->execInBackground($command, $serverLogsPath);
5562

5663
// Run PHP application server
57-
$this->call('serve', ['--host' => $serverHost, '--port' => $serverPort]);
64+
$this->call('serve', ['--host' => $serverHost, '--port' => $serverPort, '--env' => $serverEnv]);
5865
}
5966

6067
/**
@@ -81,7 +88,9 @@ protected function getOptions()
8188
['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000],
8289
['larasset-host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the asset files on.', "localhost"],
8390
['larasset-port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the asset files on.', 3000],
84-
['larasset-environment', null, InputOption::VALUE_OPTIONAL, 'Specifies the environment to run this server under (test/development/production).', 'development'],
91+
['larasset-env', null, InputOption::VALUE_OPTIONAL, 'Specifies the assets environment to run this server under (test/development/production).', 'development'],
92+
['larasset-environment', null, InputOption::VALUE_OPTIONAL, "DEPRECATED: Use '--larasset-env' option instead."],
93+
8594
];
8695
}
8796

0 commit comments

Comments
 (0)