Comments (6)
I would +1 the should be stored in .env.x.php git ignored files as this helps with per environment configuration of legacy laravel 4 applications.
However watch out for using plain getenv()
for boolean/null/int values in Laravel 4, Laravel 5 has an env()
function in helpers.php
which translates strings provided by the php ENV variables back into their appropriate types.
A string getenv()
of false for breadcrumbs.sql_bindings
or user_context
may evaluate to true accidentally enabling the feature. Also if getenv() fails it will return false which is handled better by the laravel helper function from memory.
For Laravel 4 I pulled out the env() function and put it into a polyfill composer library (https://github.com/zVPS/laravel-4-env-polyfill) which can be useful for setting the dsn & app configs in a Laravel 5 compatible way:
<?php
return [
'dsn' => env('SERVICES_SENTRY_DSN', ''),
// capture release as git sha
'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')),
// Capture bindings on SQL queries
'breadcrumbs.sql_bindings' => env('SERVICES_SENTRY_SQL_BINDINGS', true),
// Capture default user context
'user_context' => env('SERVICES_SENTRY_USER_CONTEXT', true),
];
.env.local.php
'SERVICES_SENTRY_DSN' => 'http://secure:thingy@localhost:6700/2',
'SERVICES_SENTRY_SQL_BINDINGS' => 'true',
'SERVICES_SENTRY_USER_CONTEXT' => 'true',
Hope this helps any peoples still on Laravel 4
from sentry-laravel.
The best way to do production only would be to log Sentry in all environments but only set DSN in production. This ensures you are running nearly the same code in dev and prod but disables reporting in dev.
from sentry-laravel.
@dcramer Thanks for your reply. I've just noticed the config file which is published in the L5 version references an env variable:
return array(
'dsn' => env('SENTRY_DSN'),
..
);
I'd be happy to submit a pull request to add this functionality (using the core getenv
function) to the L4 config file if you think this would make this approach clearer.
from sentry-laravel.
I think the only reason we don't use env in laravel 5 (as a default) is because I didn't know about getenv.
We should probably:
- add that
- add defensive hooks for the original issue you hit here
from sentry-laravel.
(Assuming you meant Laravel 4 here) The notion of environment variables did exist in Laravel 4 (https://laravel.com/docs/4.2/configuration#protecting-sensitive-configuration), but doesn't appear to be the preferred method of defining environment configuration.
I would say however that the DSN comes under the bracket of "sensitive configuration", and is certainly environment specific, and therefore better suits being stored in a git-ignored .env.X.php file, rather than in a committed config file
N.B. Laravel suggest using the $_ENV['prop']
retrieval method rather than the getenv()
function. The latter will gracefully fail if no matching environment variable has been defined, which would be the desired behaviour in Sentry's case.
from sentry-laravel.
^ above is really good advice for people still running 4.x and who have not solved this issue another way. However we would be soon dropping 4.x support (the 0.8.x versions will keep working on L4) while moving forward with 5.x support so we are not going to address this in the package ourselfs.
from sentry-laravel.
Related Issues (20)
- Lumen does not have the `Illuminate\Routing\Events\RouteMatched event`. HOT 1
- Report missing translations
- Unable to set up sentry sdk debug logger option in Laravel 7 HOT 11
- Data not being send to Sentry HOT 2
- [Cron Monitoring] Whether to consider adding a switch configuration option for Cron monitoring? HOT 2
- Configure Cron Monitoring based on environment HOT 1
- Idle timeout reached HOT 4
- Scheduled task tracing
- Disabling SSL Verify Peer HOT 2
- Add support for Laravel 11.0's Context
- Link to Laravel v10 docs broken HOT 2
- Dependency nyholm/psr7 can be defined like require-dev HOT 1
- Does captureUnhandleException still work for Laravel 11 HOT 1
- SQLSTATE[HY000]: General error: 2006 MySQL server has gone away HOT 6
- Metrics Rate Limits HOT 1
- Wrong stack trace when using in-app middleware HOT 6
- FilesystemAdapterDecorator incompatibility in tests. HOT 2
- Performance monitoring doesn't work in artisan commands
- LighthouseIntegration does not report all the traces to Sentry HOT 4
- Call to undefined function Sentry\metrics() HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sentry-laravel.