Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save koshuang/398b2257c325d96eccfa10c03b1d2ae9 to your computer and use it in GitHub Desktop.
Save koshuang/398b2257c325d96eccfa10c03b1d2ae9 to your computer and use it in GitHub Desktop.

用 grep + regularexpression 顯示 laravel config 所有用到的 env

希望把下面的原始內容,取出只有在 env('') 裡面的文字,也就是所有用到的環境變數。

原始內容

 grep "env('" config/*s.php
config/filesystems.php:    'default' => env('FILESYSTEM_DRIVER', 'local'),
config/filesystems.php:    'cloud' => env('FILESYSTEM_CLOUD', 's3'),
config/filesystems.php:            'url' => env('APP_URL').'/storage',
config/filesystems.php:            'key' => env('AWS_ACCESS_KEY_ID'),
config/filesystems.php:            'secret' => env('AWS_SECRET_ACCESS_KEY'),
config/filesystems.php:            'region' => env('AWS_DEFAULT_REGION'),
config/filesystems.php:            'bucket' => env('AWS_BUCKET'),
config/filesystems.php:            'url' => env('AWS_URL'),
config/services.php:        'domain' => env('MAILGUN_DOMAIN'),
config/services.php:        'secret' => env('MAILGUN_SECRET'),
config/services.php:        'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
config/services.php:        'token' => env('POSTMARK_TOKEN'),
config/services.php:        'key' => env('AWS_ACCESS_KEY_ID'),
config/services.php:        'secret' => env('AWS_SECRET_ACCESS_KEY'),
config/services.php:        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
config/services.php:        'secret' => env('SPARKPOST_SECRET'),
config/services.php:        'key' => env('STRIPE_KEY'),
config/services.php:        'secret' => env('STRIPE_SECRET'),
config/services.php:            'secret' => env('STRIPE_WEBHOOK_SECRET'),
config/services.php:            'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300),

結果

grep -ohPR "env\('(\K\w+)" config
FILESYSTEM_DRIVER
FILESYSTEM_CLOUD
APP_URL
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION
AWS_BUCKET
AWS_URL
MAILGUN_DOMAIN
MAILGUN_SECRET
MAILGUN_ENDPOINT
POSTMARK_TOKEN
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION
SPARKPOST_SECRET
STRIPE_KEY
STRIPE_SECRET
STRIPE_WEBHOOK_SECRET
STRIPE_WEBHOOK_TOLERANCE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment