I'm currently trying to develop my own Artisan Scripts. And for that, I need to load another environment than only "local".
I've created 3 files : ".env.local", ".env.development", ".env.production" and during the deployment, I create a Symlink from .env.XXX to .env
That's working.
Now, with my Artisan in CLI-mode; I want to just call my method with that :
php artisan --env=development myowncommand:exec
... where "development" is my .env.**** file.
I should call other environments by :
php artisan --env=local myowncommand:exec
php artisan --env=development myowncommand:exec
php artisan --env=production myowncommand:exec
That doesn't work.
What am I doing wrong ? Any idea ?
Thanks,
This is somewhat of a hack, but you can leverage loadEnvironmentFrom(). Copy the "artisan" file in the root directory to "artisan-local", "artisan-development", etc.
In the file, under the line:
$kernel = $app->make('Illuminate\Contracts\Console\Kernel');
Add:
$app->loadEnvironmentFrom('.env.local');
Change '.env.local' as appropriate.
Related
I'm using DreamFactory REST API in a Docker container and I need to disable wrapper "resource" in payload. How can I achieve this?
I have replaced the following in all of these four files:
opt/bitnami/dreamfactory/.env-dist
opt/bitnami/dreamfactory/vendor/dreamfactory/df-core/config/df.php
opt/bitnami/dreamfactory/installer.sh
bitnami/dreamfactory/.env
DF_ALWAYS_WRAP_RESOURCES=true
with:
DF_ALWAYS_WRAP_RESOURCES=false
but this doesn't fix my problem.
The change you describe is indeed the correct one as found in the DreamFactory wiki. Therefore I suspect the configuration has been cached. Navigate to your DreamFactory project's root directory and run this command:
$ php artisan config:clear
This will wipe out any cached configuration settings and force DreamFactory to read the .env file in anew. Also, keep in mind you only need to change the .env file (or manage your configuration variables in your server environment). Those other files won't play any role in configuration changes.
I'm trying out MGT Development Environment 7.0 and installed a fresh copy of Magento 2.
every time after php bin/magento setup:upgrade, and reload the page, generated files in var, pub, generated have different user and group clp:clp.
Instead of running chmod -R 777 . every time. Can anyone suggest a better solution?
Thank in advance.
After view phpinfo(), found out that php in running by user clp
Simply chown the webroot clp:clp and everytime run php command by sudo -u clp php yourCommand, which solve the problem.
I have got some problem with migration.
I create new migrate file
php artisan make:migration create_menu_table --create=menu
then i edit the new Migration file
and when i try migrate it's not working
I tried:
php artisan migrate
php artisan migrate --force
php artisan migrate:refresh
php artisan migrate:refresh --seed
php artisan migrate:rollback
php artisan migrate:reset
but they do not add created table
I do not have any errors
Thanks for help
Run composer dumpautoload and then try php artisan migrate:refresh again.
Hope this helps!
add schema ::defaultStringLength(191) to migrate file(put in every file migrate)
like this
public function up()
{
schema::defaultStringLength(191);
Schema::create('products', function (Blueprint $table) {
$table->increments('id');
$table->string ('Name');
$table->float('price');
$table->timestamps();
});
}
I used the command "php artisan migrate:reset" and "php artisan migrate:refresh" both gives the error
[Symfony\Component\Debug\Exception\FatalErrorException]
Class '' not found
I also need to remove column from table using migration in laravel 5.1, please guide me or send me any reference links.
I attached my error screen here .
Thanks
When I get an issue like this I usually dump the autoloader:
composer dump-autoload
To remove a column from the database you can either remove it from you migration and run:
php artisan migrate:refresh
Which is usually fine in a development environment, but you will lose any data in your database, so it's a good idea to set up some seeders if you want to do it this way.
Otherwise, you can create a new migration to simply drop your column using:
php artisan make:migration drop_my_column_from_my_table --table=my_table
You would then do something like:
Schema::table('my_table', function ($table) {
$table->dropColumn('my_column');
});
and run you migration as normal:
php artisan migrate
I need to pass a large number of environment variables to Rails application ran by Unicorn web server. The sample unicorn init script has the following lines:
APP_ROOT=/home/x/my_app/current
<...>
INIT_CONF=$APP_ROOT/config/init.conf
<...>
test -f "$INIT_CONF" && . $INIT_CONF
So I created a $APP_ROOT/config/init.conf, put all my variables there like this:
VAR1=value1
VAR2=value2
I even made this file executable (not sure if it is necessary)
And restarted Unicorn. But ENV["VAR1"] returns nothing in my application...
Is it supposed to work this way? If yes, what am I doing wrong? If no, then how can I pass many env vars into Rails app in a clean way? (without polluting global environment or putting all of them in the command line)
Update My investigation showed that shell file like this:
. init.conf
echo $VAR1
works as expected. But this one:
. init.conf
ruby -e "puts ENV['VAR1']"
does not. So . imports code into the script but env vars set this way are not transferred further.
You probably have to "export" the variables from within the config file. Does it work if you put
export VAR1=value1
export VAR2=value2
into the config file?
I would consider using foreman, specifically for its use of .env files as defined here.