How to use sentry-cli for self hosted Sentry - sentry

I am trying to use command:
sentry-cli sourcemaps explain $EVENT --org $ORG --project $PROJECT_NAME
but response is
error: API request failed
caused by: sentry reported an error: Invalid token (http status: 401)
My token is of course right in .sentryclirc.
With adding option --log-level=debug I noticed, that sentry-cli is trying to use Host: sentry.io, what is wrong.
So I tried to add parameter --url $URL to have
sentry-cli sourcemaps explain $EVENT --url $URL --org $ORG --project $PROJECT_NAME
but response is:
error: Found argument '--url' which wasn't expected, or isn't valid in this context
If you tried to supply `--url` as a value rather than a flag, use `-- --url`
How can I use sentry-cli sourcemaps explain command for self hosted sentry then?

An alternative way is to provide the URL in .sentryclirc file:
[defaults]
url=your-custom-sentry-url

Right command is
sentry-cli --url $URL sourcemaps explain $EVENT --org $ORG --project $PROJECT_NAME

Related

Executing config:cache command during deployment

I have a secret test key for a payment gateway in the .env file.
APP_TIMEZONE = 'Africa/Lagos'
APP_PAYSTACK_KEY = sk_test_b6c0b4925403blablabla
Reason is that other people working on the project can use their own test key if they have. So in a payment controller i get the value of this key like so:
"authorization: Bearer " .env('APP_PAYSTACK_KEY' , 'sk_test_b6c0b4925403blablabla')
During deployment I intend running config:cache so that Laravel won't be going a long trip in getting the required configuration setups. But from Laravel documentation :
If you execute the config:cache command during your deployment
process, you should be sure that you are only calling the env
function from within your configuration files. Once the configuration
has been cached, the .env file will not be loaded and all calls to
the env function will return null.
So my question is how can I set this APP_PAYSTACK_KEY in the config file and how to retrieve it anywhere in my app?
You can add paystack to your config/services.php file:
<?php
return [
/*
|--------------------------------------------------------------------------
| Third Party Services
|--------------------------------------------------------------------------
|
| This file is for storing the credentials for third party services such
| as Stripe, Mailgun, SparkPost and others. This file provides a sane
| default location for this type of information, allowing packages
| to have a conventional place to find your various credentials.
|
*/
// ...
'paystack' => [
'key' => env('APP_PAYSTACK_KEY', 'sk_test_b6c0b4925403blablabla'),
],
];
Then call config() helper method instead of env() on your controller:
"authorization: Bearer " .config('services.paystack.key')
Now you're safe to cache your configs via calling php artisan config:cache.

Invalid API key: You must be granted a valid key tmdb laravel 5.5

i am trying to install php-tmdb/laravel on my laravel 5.5 but getting error on basic test
Invalid API key: You must be granted a valid key
i try with google and found this link https://github.com/php-tmdb/laravel/issues/38
but its not working or can't understand
help me
auto discovery in this package is not working correctly
just add this on providers
config/app.php
Tmdb\Laravel\TmdbServiceProvider::class,
everything is working fine now
According to the github README.md https://github.com/php-tmdb/laravel
After you install the package, run this command to publish the configuration file:
php artisan vendor:publish --provider="Tmdb\Laravel\TmdbServiceProviderLaravel5"
then edit this file: config/tmdb.php in your application with your api key.
The configuration file should look like this:
https://github.com/php-tmdb/laravel/blob/master/src/config/tmdb.php
Notice 'api_key' => '', fill this in and then re-run your code/test.
Here's where you get your API key from: https://developers.themoviedb.org/3/getting-started
After changing the config, for good measure; clear your config cache with this command:
php artisan config:clear
edit /vendor/php-tmdb/laravel/src/config/tmdb.php
find 'api_key' => '', and add your key here.

cURL not working in laravel

I am doing a custom SMS gateway integration with Laravel. I used curl for that. Curl is already enabled in my localhost(XAMPP, ubuntu) and I can use curl in simple PHP. But when I try to call curl_init() in laravel leads to an error FatalErrorException in Builder.php line 311:
Call to undefined function Ixudra\Curl\curl_init(). When I use var_dump(function_exists('curl_version')); , I got bool(false). How can I use curl in Larvel
Check php.ini for the extension=php_curl.dll and make sure it is enabled. If not,enable it and restart xampp. Check the first answer here for a sample request.

Lumen with Dingo API routes not defined

Have a fresh install of Lumen 5.2 and new install of Dingo 1.0.*#dev
I have installed the service provided in bootstrap/app.php
Also setup .env file eg
API_VERSION=v1
API_PREFIX=api
API_SUBTYPE=app
API_DEBUG=true
In the Http/routes.php I have added a test route eg
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', ['namespace' => 'App\Http\Controllers\V1'], function ($api) {
$api->get('example', 'ExampleController#test');
});
This route is not working plus in command line if I try php artisan api:routes
I get error
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "api:routes" is not defined.
Did you mean this?
api:docs
Have I missed something? Also using HTTP Basic if it helps?
In Dingo Documentation -> Creating API Endpoints section you can find this sentence:
"If you're using Laravel 5.1 you can see the registered routes using Artisan.
$ php artisan api:routes
"
If you also run
$ php artisan list
only api:docs is available - api:routes is missing.
That means that this command do not work in Lumen.
composer requires jakubkratina/lumen-dingo-route-list
Add the following code in app/Console/Kernel.php:
protected $commands = [
\JK\Dingo\Api\Console\Commands\RouteListCommand::class
];
By default, as shown in docs, lumen don't ship with api:routes. But you can use lumen-dingo-route-list from jakubkratina. It will add route:list to your artisan.
By the way, I'd to do some adjustments to get it working:
First, include the backlash into the registration
protected $commands = [
\JK\Dingo\Api\Console\Commands\RouteListCommand::class
];
And last, edit vendor/jakubkratina/lumen-dingo-route-list/src/RouteListCommand.php and add this code:
public function handle()
{
return $this->fire();
}

Installing and using Mink with Browserkit driver

I seem to be unable to install Mink with Browserkit driver on Centos.
I am using these instructions: https://github.com/minkphp/MinkBrowserKitDriver
The steps I am taking is by:
adding a file in my project directory with the name composer.json and the contents:
{
"require": {
"behat/mink": "~1.5",
"behat/mink-browserkit-driver": "~1.1"
}
}
Use the commands as below.
$> curl -sS https://getcomposer.org/installer | php
$> php composer.phar install
Now there are 3 files (composer.json, composer.lock, composer.phar) and one folder (vendor) in the project directory. Where do I run the "Usage example" code from (as on the documentation)?
I have tried adding require_once "vendor/autoload.php"; to my test.php file:
<?php
require_once "vendor/autoload.php";
use Behat\Mink\Mink,
Behat\Mink\Session,
Behat\Mink\Driver\BrowserKitDriver;
use Symfony\Component\HttpKernel\Client;
$app = require_once(__DIR__.'/app.php'); // Silex app
$mink = new Mink(array(
'silex' => new Session(new BrowserKitDriver(new Client($app))),
));
$mink->getSession('silex')->getPage()->findLink('Chat')->click();
but getting a fatal error that app.php cannot be opened. I have also tried adding the following to test.php:
require_once 'vendor/behat/mink-browserkit-driver/tests/app.php';
Any help would be appreciated :)
Its seems you're missing some guideline in order to organize your code. Before integrating Behat and Mink, first of all you should organize your Silex project. My advice is for you to take a look at the official Silex Skeleton project.
After that you can start by installing behat, mink and your driver:
cd path/to/your/silex/project/root
composer require behat/behat:~2.5 behat/mink behat/mink-browserkit-driver
Then you can initialize behat.
bin/behat --init
Then configure your mink driver in behat.yml (on your project root directory)
default:
extensions:
Behat\MinkExtension\Extension:
browserkit: ~
base_url: http://my.dev.host
Notice that browser kit cannot execute JS, remember that (if you want to execute JS on your tests, you should install another driver)
After that you can start writing your features on the features directory (behat should've created that for you), for example if you have this controller in src/controllers.php:
<?php
//...
$app->get('/hello', function () use ($app) {
return new Response("Hello world!");
});
You can write the feature (on features/greeting.feature):
Feature: Greetings from /hello page
In order to say hello world
As a visitor
I need to go to the /hello page and see Hello world!
Scenario: See Hello world!
Given I am on "/hello"
Then I should see "Hello world!"
Another option is to use full behat extension for silex: https://github.com/tabbi89/Behat-Silex-Extension
You can check how integrations of Mink and browserKit work there.

Resources