No hint path defined for [pagination]. Laravel 5.3 - php

I'm receiving this error on pagination, and reset password post request on Laravel 5.3. Trying to figure out what's causing since I can see that error happens on FileViewFinder.php line 112, which contains:
if (! isset($this->hints[$segments[0]])) {
throw new InvalidArgumentException("No hint path defined for [{$segments[0]}].");
}
This code is part of the getNamespaceSegment($name) method, which gets the segment of a template with a named path. Thank you in advance!

I figured out, what was happening. Basically the message says FileViewFinder cannot find the related templates that are required when pagination function is called:
$paginator->links();
So the solution is to first make sure the files are published by running:
php artisan vendor:publish --tag=laravel-pagination
And then update path to the pagination templates located in resources/views/vendor/pagination:
$paginator->links('vendor.pagination.default')

You may have error into your blade file, define the default pagination file
$paginator -> links('vendor.pagination.default')

you can set it manually
if you have your blades views in ...views/pagination, that is how you can specify it:
app('pagination')->addNamespace('mail', resource_path('views') . '/pagination');

Related

Laravel "Unable to locate a class or view for component" in production environment

I develop on a Mac locally. Latest version of Big Sur.
Today I went to deploy my app to production via an Ubuntu server through Forge, and got greeted with an error I've never seen before, and can't find an answer to online. I can see MANY people complaining about it, but all anyone has said on other answers is link to issues that don't have solutions or even explanations really, so that's why I'm asking a new question.
The exact error is this;
Unable to locate a class or view for component [layouts.base]. (View: /home/forge/default/releases/20201204084441/resources/views/layouts/app.blade.php)
In my app I have;
app\View\Components\Layouts\App.php
which looks like this;
<?php
namespace App\View\Components\Layouts;
use Illuminate\View\Component;
class App extends Component
{
public function render()
{
return view('layouts.app');
}
}
Then I also have;
resources\views\layouts\app.blade.php
<x-layouts.base>
<!-- contents -->
</x-layouts.base>
(Also pretty much the same for base)
Works flawlessly on Mac. As soon as I deploy it on Ubuntu, I get the error above that it is "unable to locate a class or view" with those names.
Can someone please instruct me on how I can go about fixing this, since so far I have absolutely no idea and despite knowing that case sensitivity is probably the issue as per the other questions about this, I cannot find any actual solution or way to resolve this.
I had the same problem. Thanks to your question, I could find out how to solve it :D
In my case, I had created a component inside another folder, for better organization sake:
$ php artisan make:component Tutorial/channelName/Alert
So it created the view component inside the following directory:
views/components/tutorial/channel-name/alert.blade.php
Now, to call your component you do it this way:
<x-tutorial.channelName.alert />
That's pretty much it.
I was facing the same issue and I fixed it by cross-checking my folder name.
Please note that the folder name should be components and not component.
Refer the screenshot for a better idea.
Example:
In case you are following the convention, one more thing is that if you have a file at
views/components/admin/side-menu/side.blade.php
You can call your Component as:
<x-admin.side-menu.side></x-admin.side-menu.side>
Explained:
The x- used in the blade syntax basically tells that you are selecting folder or file from the Components folder.
The . (dot) used is for every directory you dig to the blade file you want to use.
Well, I had the same problem but I realized that the error was the class name of the component. I didn't capitalize the class name and when I did capitalize the class name I stopped getting that error and my project worked well.
Please try capitalizing the class name that matches the component in the error message.
In my Case, I didn't provide the namespace in the Component, it solved after providing namespace.
when I was a beginner I got the same error But in my case, there is all ok but there is a small syntax error <x- card /> there is a gap between card and dash which is not correct so there should be no space between dash and card <x-card /> so try once maybe this is your problem.
I had the same problem - solution
was to change:
<x-forms.inputradio>
to:
<x-forms.inputRadio>
just letter size..
The issue for the mentioned problem is case sensitive,
for local looks like its case insensitive reasons its works for local perfect but breaks on serve.
if you have create new component inside any new folder
i.e
$ php artisan make:component Widgets/CustomAlert
it will create two files, class and blade file for the component.
class file
app\Views\Components\\CustomAlert.php
blade file
resources\views\components\widgets.custom-alert.blade.php
you can render component with either class or with blade file.
for class make sure folder, class name in case sensitive
ie.
<x-Widgets.CustomAlert />
to render blade file it should be
<x-widgets.custom-alert />
Note
if you have manually relocate the file, make sure your namespace in class file, filename and the component call syntax should be match(with case sensitive)
examples are just for reference try to compare syntax and names with your files,folder.
I hope it will help :)
In my case, I had created a class AppLogo and I had the blade generated as app-logo.blade.php.
However, in my view files, I referenced the component as x-applogo and this worked locally, but in production (a live hosting server), I got this error.
SOLUTION:
I changed all occurrences of x-applogo in my blade/view files to x-app-logo.
This worked both in development and in production.
Hope this helps someone out there.
This happens at server. try not to make components inside folder..
i had the same issue at server but did not get any solution,
the only solution worked is to keep your components outside any sub folder

Laravel cannot find a Controller Method (does not exist)

I'm trying to implement a new method in a BoController called "deleteBooking", the method is defined:
public function deleteBooking($id){
$booking = Reservation::find($id);
if($booking && $booking->delete()){
try {
$email = Mail::to($booking->user_email)->send(new Cancel($booking));
} catch(\Exception $e){
Log::error($e->getMessage());
}
return redirect('admin/manager/home')->with('message','Réservation annulée!');
}
return redirect('admin/manager/home')->with('message','Réservation non annulée!');
}
But laravel at the endpoint says:
(1/1) BadMethodCallException
Method [deleteBooking] does not exist.
Other methods from the same class are linked to endpoints too, and work well.
Do you have any ideas please? Thank you.
I got it fixed, I've found another file called BoController, in another folder somehow and it was conflicting with the App\Http\Controllers one.
Thank you.
It's most likely that you have declared that function for some other request type other than the one you're trying to make. For example you put Route::post('some-method', 'BoController#deleteBooking'); but you need to put either Route::get(...) or Route::put(...) or Route::delete(...).
If it isn't that problem, then you probably misspelled it.
I have faced similar issue. Then I have figured out a issue pointed in composer install log, with following instance of log line:
Class App\Http\Controllers\BlogController located in ./app/Http/Controllers/BlogControllerOld.php does not comply with psr-4 autoloading standard. Skipping.
Based on that I have found that one of the file renamed with Old suffix was creating conflict with the main file. So here I have to chhoseone of the following solutions:
To delete the file created for backup.
Or just rename the class in duplicated file to BlogControllerOld.
So its a good idea to check for issues with composer install
It will highlight the conflicts that can be fixed using one of the method above.
Once fixed using specified methods above issue composer install to apply the fix and regenerate autoloader.

Call to undefined method ActiveRecord\Config::initialise() composer

Hey everyone I'm following a tutorial on Composer, I've installed ActiveRecord and I'm trying to create a database model. Whenever I load the page though I get this error: Call to undefined method ActiveRecord\Config::initialise()
Here's my setup file in index.php
require_once "vendor/php-activerecord/php-activerecord/ActiveRecord.php";
ActiveRecord\Config::initialise(function($cfg) {
//setting up a model (which is the representation of a table)
$cfg->set_model_directory('models');
$cfg->set_connections(array(
'development' => 'mysql://root:tutsplus#localhost/blog'
));
});
$posts = Post::all();
print_r($posts);
?>
And here's where I declare Post
class Post extends ActiveRecord\Model{}
I really cannot find the reason this isn't working, I actually did this instead to see if manually creating a new Post instance would fix the initialisation problem but it didn't, it had exactly the same error:
$post_class = new Post;
$posts = $post_class->all();
print_r($posts);
I'm really stumped on this one, I've usually managed to find something that fixes my problem on here but this is just nope. There is literally no difference to the tutorial code that I can see and I've checked it loads of times. Any help would be greatly appreciated.
(edit: the duplicate php-activerecord folders at the top isn't a code problem, the folder is actually duplicated and I haven't got round to moving the contents yet)
Point one: When using Composer, you are supposed to only include "vendor/autoload.php", and nothing else. Composer does the rest of autoloading for you.
Point two: It is called initialize with a Z, not S. You might simply have misspelled that method name.

Propel Data Load - "default" context does not exist

I am currently stuck on the error The "default" context does not exist. when trying to build my data model with the command symfony propel:build --application=frontend --all --and-load --no-confirmation
After lots of Googling it appears this error is caused by using sfContext inside a model or a form so I have found these and commented them out (see below), the error still occurs, does anyone else know a fix?
>> file- /var/www/html/dev/meeting/config/generated-sfGuardPlugin-schema.xml
>> file- /var/www/html/dev/meeting/config/generated-schema.xml
>> propel load data from "/var/www/html/dev/meeting/data/fixtures"
>> propel load data from "/var/www/html/dev/meeting/plugins/sfGuardPlugin/data/fixtures"
The "default" context does not exist.
grep -R sfContext lib/model/*
lib/model/MeetingMeetings.php: return "";//sfContext::getInstance()->getController()->genUrl('meeting/show?id='.$this->getId(), $full);
lib/model/sfGuardUserProfile.php: //if(!is_null(sfContext::getInstance())&&($useYou||$useYourself)&&$this->getUserId()==sfContext::getInstance()->getUser()->getId()) {
grep -R sfContext lib/form/*
lib/form/MeetingMeetingsForm.class.php: //sfContext::getInstance()->getUser()->setFlash("info",
Many thanks for your time,
Not sure what information I can provide, does anyone have any other questions?
I resolved this problem by doing the following.
First find all references to sfContext in your model files and find an alternative way to get what ever sfContext was needed for (for example passing it to the method).
Check all library files mentioned inside any models for use of sfContext, repeat above solution.
Use is_null checks on sfContexts where it has to exist so it only does if it required.
The problem in my case was my save method used another library which used sfContext to get the current user, which obviously doesn't exist when inserting data to the model
Just ran into this today with data-load. Instead of modifying the function signature, here's what I did.
if(!sfContext::hasInstance())
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'cache', true);
else
$configuration = sfContext::getInstance()->getConfiguration();
And then I can run stuff like this in my model classes.
$configuration->loadHelpers('Texturizer');
I'm not sure what the 'cache' parameter does in getApplicationConfiguration, but I found that line off of the Jobeet book here http://www.symfony-project.org/jobeet/1_4/Propel/en/21
To resolve the problem quickly, comment the code /lib/form/baseForm.class.php , generate the module, and restores the code

CodeIgniter: Can't Get My New Controller/View To Show

I am learning how to use codeIgniter as my php framework. I am reading through the documentation and watching the intro video and just generally following along with the first tutorial, but it's not working for me.
I have created a controller called "test.php" and a view called "test_view". The controller for this class is exactly like "welcome.php" and the view file just has some static html. However, when I go to index.php/test I get a 404 error.
I have also tried manipulating the original welcome files so that instead of calling a view it just echos "testing", yet I still see the original welcome message! I've tried clearing my browsing cash and refreshing, but to no avail.
Any suggestions? Thanks.
Edit: Here's the code for controllers/test.php
<?php
class Test extends Controller {
//Just trying to get it to echo test
public function index()
{
echo "test";
//$this->load->view('test_view');
}
}
?>
Try looking at this page in the documentation - this might solve your problem.
This basically means you should try typing index.php?/test/ instead (notice the question-mark).
First of all, check the above link. Might be useful.
If not, then...
Try changing the default controller in the config file ('routes.php') to something else (probably, to 'test'), then try loading index.php. Just to test whether the whole system works (or not).
Check whether mod_rewrite is loaded (in your server .conf-file, if you're using Apache).
Try using the latest build of the framework. AFAIK, the name of the controller class for now is "CI_Controller".
Finally, try removing the word 'public' before the declaration of the function. AFAIR, CI enable you to make private functions in controllers just by using prefix (which is set in the config file) at the beginning of the name of the function (thus making all the other functions public).
But most certainly the problem is with the mod_rewrite. If not, try debugging with die('Page found'); instead of echo - this will allow you to track possible redirects on the page.

Categories