I develop my Laravel applications using Windows with Laravel Homestead. In Laravel Homestead I am using PHP 8.0.21 and Laravel 9.23.
I deployed my project to a host without any errors. However, Laravel does not recognize the PHP class of Blade components, making it impossible to use the application.
It is as if the component were anonymous. I put a dd('hi') in the class construct and nothing happens.
I cleared all Laravel caches using artisan optimize:clear. I cleared all server caches. I checked access permissions. Nothing solved, still not being able to use the application.
In my local environment the application works, but in hosting it doesn't. I don't know what else to check as there is no error log.
The hosting PHP version is 8.0.20, I don't believe that's the reason for the problem.
Can you help me?
Component call
<x-admin.sidebar.sidebar-main />
Component
<div>
The only way to do great work is to love what you do. - Steve Jobs
</div>
Class Component
<?php
namespace App\View\Components\admin\sidebar;
use App\Models\Menu;
use Illuminate\View\Component;
class SidebarMain extends Component
{
/**
* Menus da área administrativa.
*
* #var array
*/
public array $menus;
/**
* Create a new component instance.
*
* #return void
*/
public function __construct()
{
dd('xxxxxxxxxxx');
}
/**
* Get the view / contents that represent the component.
*
* #return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.admin.sidebar.sidebar-main');
}
}
Related
Am working on an app using Laravel Nova and wanted to implement a calendar from https://github.com/czemu/nova-calendar-tool.
I followed all instructions but have received the following error:
Class Czemu\NovaCalendarTool\NovaCalendarTool contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Laravel\Nova\Tool:: menu)
Here's my code throwing me the above error.
<?php
namespace Czemu\NovaCalendarTool;
use Laravel\Nova\Nova;
use Laravel\Nova\Tool;
class NovaCalendarTool extends Tool
{
/**
* Perform any tasks that need to happen when the tool is booted.
*
* #return void
*/
public function boot()
{
Nova::script('nova-calendar-tool', __DIR__.'/../dist/js/tool.js');
Nova::style('nova-calendar-tool', __DIR__.'/../dist/css/tool.css');
}
/**
* Build the view that renders the navigation links for the tool.
*
* #return \Illuminate\View\View
*/
public function renderNavigation()
{
return view('nova-calendar-tool::navigation');
}
}
To be honest, this is the first time encountering such an error and have no idea what to do (coding noob). Just wanted my calendar to show up on my Nova resources.
Nova 4 doesn't support that package, its outdated.
Check https://novapackages.com/?tag=all&search=Calendar+Tool to make sure if a package is tagged under nova 3 or nova 4
There is an alternative package: https://github.com/wdelfuego/nova-calendar
So, I'm exploring the world of Jetstream and Fortify. Problem is that I want to change the default app.blade.php to my folder admin/app.blade.php.
Where is this defines so I can change it? Can't find it anywhere.
Many thanks!
(Ps: Don't know if this is categorised under Laravel of Vue.)
Update: To avoid confusion. I installed a fresh installation of Laravel with Jetstream. I'm using Inertia for developing my CMS. Inertia has a default file in /views. This is called app.blade.php, which calls #inertia. I want to move this file to /views/admin. If I do that, I get this error:
View [app] not found.
Which makes sense, because I moved it. Where do I change the render of app.blade.php to change it to admin/app.blade.php?
UPDATE:
You can register this in your AppServiceProvider.
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Inertia\Inertia;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* #return void
*/
public function register()
{
if (request()->is(['admin', 'admin/*'])) {
Inertia::setRootView('admin.app');
}
Inertia::setRootView('app');
}
/**
* Bootstrap any application services.
*
* #return void
*/
public function boot()
{
//
}
}```
do like this
YourProjectPath/config/view.php
'paths' => [
resource_path('views/admin'),
],
if in Controller you can do like this
return view('admin.app');
I am developing a website using Laravel, with a WordPress Blog section running in parallel and independently.
Since Laravel 5.3 everything run smoothly, using a Service Provider I was able to include 'wp-load.php' with a require_once() call and use all WordPress function out of the box and get/update WordPress posts.
Unfortunately, in Laravel 5.4 the helper function __() has been defined and this generates a conflict with the same WP function declared in l10n.php.
I tried using namespaces but with no luck.
This is the code of my Service Provider:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class WordPressServiceProvider extends ServiceProvider
{
/**
* Path to our WP installation
*
* #var string
*/
protected $bootstrapFilePath = '/wp-paths/wp-it-news/wp-load.php';
/**
* Bootstrap the application services.
*
* #return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* #return void
*/
public function register()
{
if (\File::exists(public_path() . $this->bootstrapFilePath))
{
require_once(public_path() . $this->bootstrapFilePath);
}
}
}
You can include wp-load.php before vendor/autoload.php in bootstrap/autoload.php
I ended up using WordPress API, as Cbroe suggested.
Docs here
curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/posts
Using php session in laravel 5 seems impossible to me. But there is no limit to knowledge.
I got a project from somebody in which php session was used in a laravel project. The project is so huge that converting the php sessions to laravel session is a huge task.
But it seems that the php session supports to work on localhost i.e. wamp and the project seems bug free. But deploying on the server its a mess. The server is a linux server. i tried to replicate the setttings to wamp. But can't get it working.
Is there any minor chance of making the application working without going through the whole project.
Got a fix to it.
The solution was
Since the project was to large to change the whole code so i added a small piece of code in the AppServiceProvider
<?php
namespace App\Providers;
session_start();
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* #return void
*/
public function boot()
{
$this->composer();
}
/**
* Register any application services.
*
* #return void
*/
public function register()
{
}
public function composer(){
view()->share($_SESSION);
}
}
Which defined as a variable in the whole Laravel project as well as session variables to where ever required.
Even though this is not the right way to use session but it helps to fix the issue.
I'm playing around with packages and I'm able to my code to work (in my controllers) when I do this:
App::make('Assets')->js('bla');
Now I want to set up a static facade so I can do this:
Assets::js('bla');
for this and I'm getting errors. I've been following this blog entry and haven't had any trouble up to this point. But now I'm stuck with a " Call to undefined method" error.
I'm not sure what code you'd need to see, so here's everything: https://github.com/JoeCianflone/msl/tree/jc-working
Specifically here is my workbench: https://github.com/JoeCianflone/msl/tree/jc-working/workbench/Joecianflone/Assets
And here is the controller where I was messing around with it: https://github.com/JoeCianflone/msl/blob/jc-working/app/controllers/HomeController.php
Any help greatly appreciated.
Looks like it was an issue with namespacing, I got it working by changing this:
<?php namespace Joecianflone\Assets\Facades;
use Illuminate\Support\Facades\Facade;
class Assets extends Facade {
/**
* Get the registered name of the component.
*
* #return string
*/
protected static function getFacadeAccessor() { return 'Assets'; }
}
to this:
class Assets extends \Illuminate\Support\Facades\Facade {
/**
* Get the registered name of the component.
*
* #return string
*/
protected static function getFacadeAccessor() { return 'Joecianflone\Assets\Assets'; }
}
What I'm not sure about is why the code from the tutorial worked but mine didn't. I must have skipped a step.
Just a sidenote, if you plan to share your code with the communuty (please do) i encourage you to use 5.3 syntax. Laravel requirements is 5.3 so dont use 5.4 in your package.