laravel 4 package controller class not found - laravel

I have a workbench package named jumper. I have three controllers
-src
--controllers
-- dashboard
-- nide
-- users
I have already registered service provider for my package. There I can access two controller Auth and Nide where as I have not being able to access the Users class.
my routs are as follows :
// 1. dash package routes
Route::get('/dash', 'Jumper\Dash\Dashboard#index');
Route::controller('dash', 'Jumper\Dash\Dashboard');
// 2. auth/Users routes
Route::controller('users', 'Jumper\Dash\Users');
Route::get('/users', 'Jumper\Dash\Users#tests');
I have already run
-> artisan dump-autoload command
-> composer update
Problem is while accessing /users or running dump-autoload command it gives me
ReflectionException
Class Jumper\Dash\Users does not exist
Note :
I have already defined the same jumper/dash as name space same as for other controller
Can Suggestions ???
Regards

Related

Laravel - black-bits/laravel-cognito-auth causing issues in default route

I've installed a laravel package black-bits/laravel-cognito-auth .
When i run php artisan route:list on command line, i've the following error:
Target class [App\Http\Controllers\Auth\ResetPasswordController] does not exist.
I'm not using ResetPasswordController in that specified path.
My ResetPassword controller's path is here: \app\Http\Controllers\Api\V1\Account\ResetPasswordController.php.
I'm mainly using this project for apis.
when i search for this path in vendor folder, i can see this.
.
Since, these routes are in vendor folder, what can i do to fix this issue?

Cannot locate class of installed package

I'm writing a laravel package which contains spatie/laravel-sitemap.
I already included several external packages and I didn't encountered any issues, but for some reason I'm not able to integrate this one.
What I did is the usual:
composer require spatie/laravel-sitemap
Then I have created a Console command that have as handle method the following content:
public function handle()
{
SitemapGenerator::create(config('app.url'))
->configureCrawler(function (Crawler $crawler) {
$crawler->ignoreRobots();
})
->writeToFile(public_path('sitemap.xml'));
$this->line('<info>Sitemap generated');
}
when I execute the command registered as:
php artisan myapp:sitemap
I get:
Class "Spatie\Sitemap\SitemapGenerator" not found
The reference imported are:
use Spatie\Crawler\Crawler;
use Spatie\Sitemap\SitemapGenerator;
I also tried composer update and composer dump-autoload, same problem.
Any help?
register package class in providers array in config/app.php
Spatie\Sitemap\SitemapServiceProvider;
in the bottom of app.php file
i hope it was useful.
you can publish package using this.
php artisan vendor:publish --provider="Spatie\Sitemap\SitemapServiceProvider" --tag=sitemap-config
then
composer dump-autoload
for more details please check the document https://github.com/spatie/laravel-sitemap under Configuration

Service Provider not booting in Laravel 5.8

I've created a new service provider to observe a model (App\Providers\EloquentEventServiceProvider.php), like so:
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Staff;
use App\Oberservers\StaffObserver;
class EloquentEventServiceProvider extends ServiceProvider
{
public function boot()
{
Staff::observe(StaffObserver::class);
}
}
I've also added it to the config file (config\app.php):
return [
...
'providers' => [
...
App\Providers\EloquentEventServiceProvider::class,
...
]
...
]
The observer methods aren't working though. If I move Staff::observe(StaffObserver::class); to the AppServiceProvider class, it works just fine. So clearly this is an issue with getting my service provider to boot. I've tried php artisan config:clear, php artisan clear-compiled, composer update and composer dump but none have work. Any help is greatly aprpeciated.
your Oberservers name is wrong, as mentioned in the laravel doc observers laravel doc it should be Observers which means all of your observers should be within App\Observers instead of App\Oberservers.
so here we have 2 solutions :
1- if you want to keep the namespace App\Oberservers, you should run these 2 commands below because autoloading of the files may not work properly because we created a new folder Oberservers:
# Autoloading of files
composer dump
# Configure the cache
php artisan config:cache
2- the second solution is to just rename your actual Oberservers folder to Observers, in that way the autoloading of files will work well.

How to use this package "https://github.com/kazist/resellerclub-php-sdk" in laravel

While using the above package in laravel I'm getting error as
"Class 'Kazist\ResellerClub\APIs\Controller' not found"
Please suggest me a solution how to call the reseller club api "url" in the controller.
$request = file_get_contents('https://httpapi.com/api/domains/available.json?auth-userid=USER_ID&api-key=API_KEY&domain-name='.$slds.'&tlds='.$tlds.'');
Please help me with a solution how to declare the domain-name and tlds from the above url in laravel.
For package installation:
From terminal go to your project's root directory and run this command:
composer require kazist/resellerclub-php-sdk
And then after successful installation one new folder called kazist will be created inside project's vendor directory.
For using api calls you need to use Guzzle http client https://github.com/guzzle/guzzle or use this link.o
Edit
Yourcontroller.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use
class Yourcontroller extends Controller
{
$resellerClub = \Kazist\ResellerClub\ResellerClub(<userId>, <apiKey>, true); // Last argument is for testmode.
// Get Available TLDs
$resellerClub->domains()->getTLDs();
// Check Domain Availablity
$resellerClub->domains()->available(['google', 'example'], ['com', 'net']); // This will check google.com, google.net, example.com and example.net
}

Laravel 5 - workbench migrations [duplicate]

I am having trouble to create package in Laravel 5 as workbench has been removed.
As in this thread (How create package in Laravel 5?), Goldorak suggest that we have to create our own package structure ourselves.
So, how can I create the workbench manually and get everything ready for package development?
Using the laravel Workbench package:
You can add the illuminate/workbench package in a Laravel 5 by adding to your composer.json:
"illuminate/workbench": "dev-master"
then add the WorkbenchServiceProvider into your config/app.php file:
'Illuminate\Workbench\WorkbenchServiceProvider'
Now you need to create the config/workbench.php file since it has been removed from Laravel 5:
<?php
return [
/*
|--------------------------------------------------------------------------
| Workbench Author Name
|--------------------------------------------------------------------------
|
| When you create new packages via the Artisan "workbench" command your
| name is needed to generate the composer.json file for your package.
| You may specify it now so it is used for all of your workbenches.
|
*/
'name' => '',
/*
|--------------------------------------------------------------------------
| Workbench Author E-Mail Address
|--------------------------------------------------------------------------
|
| Like the option above, your e-mail address is used when generating new
| workbench packages. The e-mail is placed in your composer.json file
| automatically after the package is created by the workbench tool.
|
*/
'email' => '',
];
Fill your information in this config file then you will be able to use the workbench command:
php artisan workbench vendor/name
Creating your own package structure
In this exemple we will create our package called awesome in a packages directory.
Here is the package structure:
packages/
vendor/
awesome/
src/
Awesome.php
composer.json
Vendor: your vendor name, typically this is your github username.
Awesome: the name of your package
src: Where you put the business logic
To generate a composer.json file you can use this command in the packages/vendor/awesome directory:
composer init
Now we create a Awesome.php class in the src directory with a simple method:
<?php namespace Vendor/Awesome;
class Awesome
{
public static function printAwesomeness()
{
echo 'Awesome';
}
}
After that we add the package to the laravel composer.json psr-4 autoloader:
"autoload": {
"psr-4": {
"App\\": "app/",
"Vendor\\Awesome\\": "packages/vendor/awesome/src"
}
},
and we dump the composer autoloader
composer dump-autoload
Now you can use your package everywhere in your laravel 5 project. If you need some laravel specific feature like service provider or view publishing, use them as described in the Laravel 5.0 documentation.
laravel 5 Standards with out workbench.
Set 1 : install laravel as usual.
Step 2 : Create package folder and service provider
In root directory create a folder call "packages" /"vendorName"/"packageName"/src" Eg: root/packages/jai/Contact/src
now navigate to src folder and create a service provider class: "ContactServiceprovider.php"
your service provider should extend ServiceProvider which has to implement register method.
Note:If you want you can have dd("testing"); in boot function and go to step 3 but you have copied the file you might want to create views , routes , config and controllers check link below for that
Step 3 : add package path in root composer.json in your root composer.json file "jai\Contact\": "packages/jai/Contact/src/" under psr-4
"psr-4": { "App\": "app/", "Jai\Contact\": "packages/jai/contact/src/", }
Step 4 : add service provider in app config.
in your root/conifg/app.php under providers add your package service provider to hook your package in.
'Jai\Contact\ContactServiceProvider',
Step 5 : run composer dump-autoload - make sure there are no errors.
all done - now you can access your package via url - "yourwebsite/contact"
Resource from here : https://github.com/jaiwalker/setup-laravel5-package
You could use package on this named packman. composer global require "hadefication/packman", just a simple package creator for Laravel.

Resources