How to get Laravel 5 to work with Stapler? - php

I keep getting a Class Codesleeve\LaravelStapler\LaravelStaplerServiceProvider.php: not found
I have tried using Providers\L5ServiceProvider.php instead as a provider in the config\app.php but that also gives the same error when I fire composer update
Any work around?
EDIT: please note that the directory Providers is not being fetched with the rest of the package, for some reason.

Try below command:
$php composer.phar require codesleeve/laravel-stapler
Then add 'Codesleeve\LaravelStapler\Providers\L5ServiceProvider' to providers array in config/app.php.

Related

trying to run php artisan tinker returns error "file_exists(): Unable to find the wrapper "hoa" "

I'm trying to open tinker in a Laravel project, but when I run php artisan tinker I get this error:
ErrorException
file_exists(): Unable to find the wrapper "hoa" - did you forget to enable it when you configured PHP?
I can't find everything similar error online, I found only similar errors but with 'wrapper http' .
Does anyone have any suggestions? Thanks
Could this be due to custom code or a library you've imported?
I often find that if I add things to the ServiceProvider or Kernel, they run before many of the artisan commands, and if I've failed to perform the proper "if" checks first, it fails.
I suppose the question I would have in return would be; Is this a fresh Laravel install or have you got custom code and libraries running? I would check there, try removing libraries you've added, HOA from my searching doesn't appear to default to Laravel.
— Happy to revise my answer should more detail be provided
Solved with this command founded on github:
composer require psy/psysh:0.11.2 --dev

Trying to use a composer package in laravel

Im using Laravel 5.8.
Im trying to use the following package
https://packagist.org/packages/s1lentium/iptools
To install it i have run:
composer require s1lentium/iptools
Confirmed the require line is in the composer.json
"s1lentium/iptools": "^1.1"
and that the package is in "vendor/s1lentium/iptools/"
How can i reference it in the code (controller or even in a view)??
When I try to use the IP class Laravel cannot find it.
I've researched a lot and but without success. Hope anyone can lead me to the correct step.
Thanks!
Run composer dump-autoload
You must call the IP class with \IPTools\IP, or use it:
use IPTools\IP;
Hope it helps.

Clarity on the use of pragmarx/firewall package for Laravel 5.2

so I've just completed the install of antonioribeiro/firewall package for laravel, which essentially allows blacklisting and whitelist of IP address and countries.
I'm working through the section on Artisan Commands, but when i try to run 'php artisan firewall:whitelist country:za' I get the following error:
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "firewall:whitelist" is not defined.
Did you mean one of these?
firewall:list
firewall:tables
I have done all the necessary installation steps outlined in the documentation.
What am i doing wrong ? should I be using this command elsewhere ?
I am aware that these can be manually entered into the DB, but this functionality would be great to have.
I managed to fix the problem:
SOLUTION: When you run 'php artisan vendor:publish' it creates a new file called 'firewall.php' in the config directory. This is where you set default options. Simply change 'use_database' to true and the Database specific commands will work.
firewall:blacklist
firewall:clear
firewall:remove
firewall:whitelist

'There are no commands defined in the "baum" namespace' error when using "baum" for implementing Nested Set

For implement of a Nested Set for my news category I want to use Baum package.
After installing this Package via Composer and add BaumServiceProvider to config/app.php providers, I try to install a new Model named Category via Below command:
php artisan baum:install MODEL
But I faced to the following error :
[InvalidArgumentException]
There are no commands defined in the "baum" namespace.
Of course I ran php artisan command and But there were no command named Baum on generated commands list.
What should I do?
First you have to add the code below in config/app.php:
Baum\Providers\BaumServiceProvider::class
If the problem still persists configuration files may be cached. Just call:
php artisan config:clear
Make sure that you added
Baum\Providers\BaumServiceProvider::class
To the providers array in the app.php file located in config/app.php
Whenever I know that I have added something into Laravel's core files, and it's not working from the command line, I typically just run
php artisan optimize
to regenerate all of the classes, and it will typically work. Running this command is something that I find myself doing fairly often.
In AppServiceProvider.php (app\Providers) you can modify register function: public function register()
{
$this->app->register(\Baum\Providers\BaumServiceProvider::class);
}
Not sure why 5.2 have error, just tweak a bit myself.
Try add this on APP/Console/kernel.php
protected $commands = [
//Commands\Inspire::class,
// Register Baum nestedset command
Commands\BaumCommand::class,
Commands\InstallCommand::class
];
and create two files and copy BaumCommand.php and InstallCommand in /vendor/baum/baum/src/Baum/console.
then change a namespace at the top.
namespace Baum\Commands;
to
namespace App\Console\Commands;

Laravel 4 API with OAuth 2

I work on project based on Laravel 4 and I will provide Rest API, want to authenticate request using OAuth 2,
I try https://packagist.org/packages/lucadegasperi/oauth2-server-laravel
but when try to run
Route::post('oauth/access_token', function()
{
return AuthorizationServer::performAccessTokenFlow();
});
I recieved
Class 'AuthorizationServer' not found
how to solve this? or there are another tool?
You haven't followed the installation instructions provided by the package.
oauth2-server-laravel on GitHub
Add the following line to your composer.json file:
"lucadegasperi/oauth2-server-laravel": "1.0.x"
Add this line of code to the providers array located in your app/config/app.php file:
'LucaDegasperi\OAuth2Server\OAuth2ServerServiceProvider',
And these lines to the aliases array:
'AuthorizationServer' => 'LucaDegasperi\OAuth2Server\Facades\AuthorizationServerFacade',
'ResourceServer' => 'LucaDegasperi\OAuth2Server\Facades\ResourceServerFacade',
Check if the AuthorizationServer is in another Namespace. If this is the case, use that Namespace before the class name, e.g. Namespace\AuthorizationServer::performAccessTokenFlow();
If that doesn't work, try adding a \ before the class name, like this: \AuthorizationServer::performAccessTokenFlow();
Did you try those commands?
composer update
composer dumpautoload
php artisan dump-autoload

Categories