I am using Laravel 5.2. I need to get RSS feeds using SimplePie, so I install the library through composer.json and now my vendor folder contains simplepie but when i run the following code this error shows:
ErrorException in SimplePie.php line 1379: ./cache is not writeable.
Make sure you've set the correct relative or absolute path, and that
the location is server-writable.
My code in route:
Route::get('feed', function () {
$feed = new SimplePie();
$feed->set_feed_url(array(
'http://www.thenews.com.pk/rss/2/16' //it has no images
));
$feed->init();
$itemCount=$feed->get_item_quantity();
return $itemCount;
});
Create a writeable cache folder for simplepie in the /storage/ folder (I called mine simplepie_cache).
Set the path in your feed object:
$feed->set_cache_location(storage_path() . '/simplepie_cache');
That should do the trick.
check what is saying ./cache is not writeable can't write to cache folder check permissions to this folder or try a L5 wrapper for SimplePie https://github.com/willvincent/feeds
Related
I've installed a pre-made Laravel app and followed the documentation to extract it to the public root except in the documentation they are installing it into public_html, but I have it in a subdomain in a folder named "test" which is on the same level as public_html.
All the CSS and JS should be loading from the public subdirectory, but they try to look for it in the main root folder.
For example, this file returns a 404 error:
https://test.mydomain.com/css/style.css
The file is actually at this location:
https://test.mydomain.com/public/css/style.css
The absolute path of the file is:
/home/mydomain/test/public/css/style.css
Instead of:
/home/mydomain/public_html/public/css/style.css
What environment or config file isn't set correctly and how do I set it to use the correct directory?
UPDATE
Changing the ASSET_URL to "public" fixed the first issue, but now the same thing is happening with the admin.
The app tries to load the dashboard with this URL:
https://test.mydomain.com/admin/dashboard
The page loads all the assets normally when I remove the word "admin" from the URL:
https://test.mydomain.com/dashboard
But this doesn't work for all the pages.
You can try to put public directory path in below given conflagration file.
Config File Path : config/app.php (asset_url)
'asset_url' => env('ASSET_URL', 'https://test.mydomain.com/public/')
i'm new to laravel. And I have the website up now with forge. The only issue is that I cannot see or store the photos. Do I have to write the storagelink command somewhere, and if then, where exactly? I changed the file system driver to public on the env file as well
you can do that by creating the symbolic link using the facade Artisan
basically you will need to create a new route at web.php as bellow :
Route::get('/linkstorage', function () {
Artisan::call('storage:link');
});
and , of course , don't forget to import the class at the very top of the file like so :
use Illuminate\Support\Facades\Artisan;
make sure you update the hosted file as changed .
and simply , to create your symlink , you will need to navigate to /linkstorage and that's it !
I am using the Dompdf package in Laravel to download pdf's. I have the following in my web.php:
Route::get('proposal-pdf/{id}', function($id) {
$proposal = Proposal::find($id);
// $pdf = PDF::loadView('test', compact('proposal'));
$pdf = PDF::loadView('internal-admin-tools.proposal-pdf', compact('proposal'));
return $pdf->download('proposal.pdf');
return back();
});
I downloaded Dompdf using: composer require barryvdh/laravel-dompdf.
I have a view using fonts that come with Laravel. I get the following error:
fopen(C:\xampp\htdocs\HealthHub\storage\fonts/\176125b1b6dc4704cbf0390040859779.ufm): failed to open stream: No such file or directory
I added the 'fonts' directory in my 'storage' and then added the file named above. After I do that and reload, the load does not render. I think I may have to change the permissions to my 'fonts' folder and cannot find any clear answer here on how to do that. I have not done that before. I am using VSCode and XAMPP. I navigated to the 'fonts' folder in the terminal and entered: chmod mode 777. It says 'chmod' isn't recognized
Creating storage\fonts directory should fix the problem.
On my Laravel website I'm using symlink to store and show the images from storage.
With
php artisan storage:link
I had created the symlink and everytime when I upload a new news article, the image is uploaded in the main Storage and with symlink it's setup to the public folder and I'm displaying the image properly.
So far so good, but when I've created a copy of the website, a problem appears...
When I've created a copy of the website with cPanels File Manager, and move to a new location, the storage symlink in the public directory has become a folder, not a symlink.
After that when I try to upload a new news article, I can see it's uploaded in the main Storage folder, but not in the public/storage, so as a result the image is not displaying. That's because it's not a symlink anymore, but now it's a folder.
I've deleted the storage folder from the public directory, with SSH I've used the command again
php artisan storage:link
and I've created a new news article and the image is displaying properly, but now all other images are gone.
Is there any command that will regenerate the paths, so all other images will be display again?
I'm using Laravel 5.5
You can solve it in another way to create a symlinkexample.php file
into your public folder and run the file path into browser.
Then Storage folder will be created into public folder. Folder path
will be public/storage with linked to your public folder.
Code below for symlinkexample.php :
<?php
$targetFolder = $_SERVER['DOCUMENT_ROOT'].'/storage/app/public';
$linkFolder = $_SERVER['DOCUMENT_ROOT'].'/public/storage';
symlink($targetFolder,$linkFolder);
echo 'Symlink process successfully completed';
?>
Try this:
In route/web.php add the following code:
Route::get('/storage', function(){
\Artisan::call('storage:link');
return "Se han vinculado las imágenes";
});
If for some reason you are using different file structure and for some reason don't have terminal access, \Artisan::call('storage:link') will fail since it won't find public path.
Route::get('cmd', function(){
$process = new Process(['ln', '[symlink-here]','[target-folder]' ]);
$process->run();
// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
});
read about Process class here
I have a helper.php file in app/Helpers directory. I included that file in composer.json:
...
"files": [
"app/Helpers/helpers.php"
]
...
Helper works fine but I can't use public_path() method there. I need to include another file (please don't ask me why because it's old code that I don't need to rewrite). So I have the following:
require_once public_path() . '/appadmin/bootstrap.php';
I know that by default Laravel looks in /public/ folder but I faced with a problem. If I need to perform composer update I have to use public/appadmin/bootstrap.php path in helper.php, but after performing I have to change that path to /appadmin/bootstrap.php for correct work. That's why I decide to use public_path() method to receive correct path for both cases. And if I use it I'm getting an error:
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
Script Illuminate\Foundation\ComposerScripts::postUpdate handling
the post-update-cmd event terminated with an exception
[ReflectionException]
Class path.public does not exist
Thank's in advance!
Have you tried updating your app to the current revision?
There are some files in the framework itself who need to be updated.
Check out the config files, the bootstrap files, server.php and the start files here https://github.com/laravel/laravel/tree/develop.
You could open index.php (in your public directory) and change:
$app = require_once __DIR__.'/../bootstrap/app.php';
// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});
Now you dont need to change your public path when your public directory has changed.