How can I use sentry with laravel 5? - php

I have tried installing sentry in laravel 5 but it doesn't work. I would like to know if anyone has done it and how to do it.
Update: I used the instructions for Laravel 4.

I have this working.
There is no official support right now for Sentry in L5. They state this right on their website. They are working on it however.
Add the following to your composer.json file in the require section.
"cartalyst/sentry": "dev-feature/laravel-5",
"illuminate/html": "~5.0"
Add the following to the autoload section.
"app/Http/Controllers",
It should look something like:
"require": {
"laravel/framework": "5.0.*",
"cartalyst/sentry": "dev-feature/laravel-5",
"illuminate/html": "~5.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database",
"app/Classes",
"app/Http/Controllers",
"app/Models"
(Presuming linux with no aliases) Run php composer.phar dump-autoload then php composer.phar update
Follow the instructions on the following page to convert your files from 4.2 to 5.0: http://laravel.com/docs/master/upgrade#upgrade-5.0
If you are using HTML Facade for FORMS then change {{{ }}} or {{ }} for the FORM's to {!! !!} because L5 escapes all output from {{{ }}} and {{ }}. If you want raw output you must use {!! !!}.
When you move your redirect check to the boot method as per the instructions in #4 then add the following to the top of the RouteServiceProvider.php
use Cartalyst\Sentry\Facades\Laravel\Sentry;
The boot method should look something like:
public function boot(Router $router)
{
parent::boot($router);
// Check if someone is already logged in
Route::filter('members_auth',function(){
//If already logged in go to dashboard or else login
if(!Sentry::check()){
return Redirect::to('/login');
}
});
//
}
UPDATE 02-26-15
Do not run the command php artisan optimize as it will break sentry. I could not figure out what was wrong after I ran this but thought it probably has to be with the compiled.php file so I ran php artisan optimize --force and that fixed whatever the issue was.
Hope it helps.

I haven't personally installed it, but I know it's compatible. https://medium.com/#Cartalyst/laravel-5-support-4c11e01c3337
The installation instructions do not have specific Laravel5 information though it should be identical to L4 pending you pull in the correct branch. Assuming you are using composer you can do this by requiring "cartalyst/sentry": "dev-feature/laravel-5" in your composer.json.
Follow the rest of the L4 installation (add to providers and aliases array) and information except remember app.php is no longer in app/config/app.php but in config/app.php
If things are still not working for you, be sure to update your question with at least some information...

bootstarpCms use both laravel5 and sentry ,so you can read the source code to learn .here https://github.com/BootstrapCMS/CMS

Try Sentinel: https://github.com/rydurham/Sentinel
add to composer
composer require rydurham/sentinel
In config/app.php
'providers' => array(
...
'Sentinel\SentinelServiceProvider',
...
)
In app/Http/Kernel.php
protected $routeMiddleware = [
// ..
'sentry.auth' => 'Sentinel\Middleware\SentryAuth',
'sentry.admin' => 'Sentinel\Middleware\SentryAdminAccess',
];
then
publish config:
php artisan sentinel:publish
run migrations:
php artisan migrate
run seeder:
php artisan db:seed --class=SentinelDatabaseSeeder
add home route in app/routes.php
Route::get('/', array('as' => 'home', function()
{
return View::make('home');
}));
all done, go to myapp.dev/login

Related

You can not use the "render" method if the Templating Component or the Twig Bundle are not available

You can not use the "render" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".
class RecordsController extends AbstractController
{
/**
* #Route("/", name="single_page")
* #return Response
*/
public function singlePageAction()
{
return $this->render('single_page.html.twig', []);
}
}
Symfony 4 - Not rendering Twig Template
Same as for this guy but accepted answer does not help.
Tried also
composer require debug --dev
then got error
[InvalidArgumentException]
Could not find package debug.
Did you mean one of these?
symfony/debug
tracy/tracy
maximebf/debugbar
cakephp/debug_kit
symfony/debug-pack
so installed symfony/debug. Which does not make any sense but I did. Of course it did not fix the problem.
Here is how composer.json now looks:
{
"require": {
"symfony/maker-bundle": "^1.13",
"twig/twig": "~2.10",
"symfony/twig-bundle": "^4.3"
},
"require-dev": {
"symfony/debug": "^4.3"
}
}
I have installed twig 2 because otherwise could not install twig-bundle - was gettig error.
How to get rid of this error and show the template?
Update:
Noticed that my application has 2 composer.json files. One in root, another in myapp folder. Guess this is why after install it does not see because it is installed in that root directory. But now I am too angry and tired already to check, will need to do that later.
in order to use twig, after installing the package with composer, you should enable the bundle for your environment(s). Here you have the docs for the current version of symfony https://symfony.com/doc/current/bundles.html
Once you do that, you have to inject twig in your AbstractController.
If you already did all of these steps, I suggest you to add some more code, in order to allow the community to spot the problem.
I also suggest you to avoid using multiple composer.json files: use just one in your project root directory.
Goodbye!

I'am getting an error --- In ProviderRepository.php line 208: Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found

I'am new to laravel, and this is my first question because I could not find a solution anywhere.
I implemented JWT-token somehow and it worked until I mess it up. Now when I type php artisan serve I get that error, or when I try to publish. I tried everything like in question --- Laravel 5.6.26 Error- Class 'Tymon\JWTAuth\Providers\LaravelServiceProvider' not found --- but it won't work.
When I add in composer.json "tymon/jwt-auth": "^0.5.12" I get an error class LaravelServiceProvider not found, and when I change it to "tymon/jwt-auth": "^1.0.0-beta.3" or "tymon/jwt-auth": "^1.0.0-rc.2" then I ger error JWTAuthServiceProvider not found. I also tried composer require illuminate/auth but it won't work. Can I get some help please.
I had this same issue and I solved it by executing these commands
composer require illuminate/auth
composer require tymon/jwt-auth:"^1.0.0-rc.2"
composer update
Then
php artisan vendor:publish --provider="Tymon\JWTAuth\Providers\JWTAuthServiceProvider"
You can safely remove from your app.php file
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class
You need to also add the alias to config/app.php like so:
'providers' => [
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
],
'aliases' = [
....
//other aliases
...
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuthFacades\JWTFactory::class`
]
and then include it at the top of the PHP file you want to use it in, like
use JWTAuth;
Try to delete config.php file from bootstrap/cache folder, it worked with me

Can't register my custom package's dependency in Laravel5.3

I am developing a blog as a custom package for Laravel 5.3.
So far I have got the routes, controller, models and migrations working.
I am now working on the CRUD. For the forms I thought I could use this:
https://laravelcollective.com/docs/5.3/html
UPDATE
I have installed the package with composer. The dependency is in the composer.json file. The files are in my package's vendor folder.
I have also tried to run composer dump-autoload -o
From my composer.json
"require": {
"laravelcollective/html": "5.3.*"
}
I have looked everywhere and people suggest to do the following:
/**
* Register bindings in the container.
*
* #return void
*/
public function register()
{
// Bind the app.
$this->app->bind('blog', function ($app) {
return new Blog;
});
// Register LaravelCollective Form Builder.
$this->app->register('Collective\Html\HtmlServiceProvider');
$this->app->alias('Form', 'Collective\Html\FormFacade');
$this->app->alias('Html', 'Collective\Html\HtmlFacade');
}
I currently get the following error everywhere:
FatalThrowableError in Application.php line 610:
Class 'Collective\Html\HtmlServiceProvider' not found
Really not sure where I am going wrong.
UPDATE
I have tried bind instead of register:
$this->app->bind('Collective\Html\HtmlServiceProvider');
But this time I get the following error:
Class 'Collective\Html\FormFacade' not found
Make sure your composer.json contains the dependency laravelcollective/html, if not, add it to your composer.json or include it via the following command composer require laravelcollective/html
Make sure you've added the dependency to providers and aliases in config/app.php
'providers'=>[
Collective\Html\HtmlServiceProvider::class,
],
'aliases'=>[
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
],

Laravel 5.2 - Will not recognise SimpleSMS new class provider / alias

I'm trying to install https://github.com/laggards/simple-sms to my laravel 5.2 project
Within require of my composer.json I have:
"guzzlehttp/guzzle": "~6.0",
"laggards/simple-sms": "~2"
In config/app.php under providers I have:
Laggards\SMS\SMSServiceProvider::class
Under aliases I have:
'SMS' => Laggards\SMS\Facades\SMS::class
At the top of my controller I have:
use SMS;
Within the controller:
SMS::send('This is my message', [], function($sms) {
$sms->to('+44123456789');
});
Error received:
Class 'SMS' not found
I have run the following to no success:
composer update
composer dump-autoload -o
composer dump-autoload
I would appreciate any help on this :)
Try this
Add Laggards\SMS\SMSServiceProvider::class in your config/app.php configuration file within the providers array.
Then Add 'SMS' => Laggards\SMS\Facades\SMS::class in your config/app.php configuration file within the aliases array.
After this run this command- composer dump-autoload
I followed this documentation and its working for me.
https://github.com/laggards/simple-sms
Problem seems to be that the documentation is wrong if you use the ~2 version the namespace is actually SimpleSoftwareIO instead of Laggards. So either use the dev-master version so it is Laggards or change the namespace to SimpleSoftwareIO. I'm not familiar with the package so not sure what the differences are.
You can see the correct documentation for ~2 version here.
Try
use \SMS;
or
use Laggards\SMS\Facades\SMS;

Laravel 5 Class 'Illuminate\Support\Facades\FormFacade' not found

Ok, this is driving me mad. I'm trying to include forms functionalities with FormFacade with Laravel 5, but I keep getting this error:
Class 'Illuminate\Support\Facades\FormFacade' not found
I'll write down what I have done:
After laravel 5 installation, I added FormFacade to laravel.
Updated the app.php file with the following lines:
Providers:
'Illuminate\Html\HtmlServiceProvider',
Aliases:
'Form' => 'Illuminate\Support\Facades\FormFacade',
'Html' => 'Illuminate\Support\Facades\HtmlFacade',
Then, I checked my composer.json file:
"require": {
"laravel/framework": "5.0.*",
"illuminate/html": "~5.0"
},
Did a composer update
Checked if I actually downloaded the files
All of this is done, but still I cannot find whats going wrong. I searched for help but nothing seems to work.
Search effort:
Laracasts tutorial
Class 'Illuminate\Html\HtmlServiceProvider' not found Laravel 5
http://tutsnare.com/class-form-or-html-not-found-in-laravel-5/
Still no luck. Have I missed something?
PS: I'm running on windows.
Those aliases are wrong. You should use the facades from Illuminate\Html:
'Html' => 'Illuminate\Html\HtmlFacade',
'Form' => 'Illuminate\Html\FormFacade',

Categories