I am using laravel 4.2, whenever i use Log::info() or Log::Error(). The expected logs doesn't store in laravel.log instead it outputs on command prompt from where it is served. can any one suggest me how i can log those things in my laravel.log file.
I think it's for laravel only. You should create a new folder with a class of Logs.
For example:
in Folder Logs:
class example_logs{
public static function viewLogs($datas){
echo 'Your Error' . $datas;
}
}
in your Controller:
Logs::viewlogs($datas);
Related
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 trying to bind a downloadable csv template to a button which will sit in storage but i keep receiving an error i have tried below but having no luck can anyone see where i am going wrong?
Download Route
Created a download route which refers to the template in storage.
public function download()
{
return Storage::download('template.csv');
}
route file
Route::get('invites/download', 'InviteController#download')->name('invite.download');
Button
Download template
Template location
storage/app/public/template.csv
Error
This is the error i keep receiving.
League \ Flysystem \ FileNotFoundException
File not found at path: template.csv
Can i get some help to see where i am going wrong?
You can fix the issue by simply using file_get_contents() instead :
return file_get_contents(public_path('storage/template.csv'));
This will work if you have created the symlink as well php artisan storage:link,
If you want to use storage_path, then :
return file_get_contents(storage_path('app/public/'.'template.csv'));
I created a fresh Laravel project v5.8. Then installed the latest version of the Laravel Code Generator (2.3) but I'm unable to generate resources. I've read your release notes for 2.3 and I'm not seeing where I'm making a mistake on the installation or the commands I keep the output below:
php artisan create:scaffold Test generates the output below:
Exception : The file
resources/laravel-code-generator/sources/tests.json was not found!
at /Users/Sites/Laravel/lms/vendor/crestapps/laravel-code-generator/src/Models/Resource.php:686
682| {
683| $fileFullname = Config::getResourceFilePath($filename);
684|
685| if (!File::exists($fileFullname)) {
> 686| throw new Exception('The file ' . $fileFullname . ' was not found!');
687| }
688|
689| return File::get($fileFullname);
690| }
Exception trace:
1 CrestApps\CodeGenerator\Models\Resource::jsonFileContent("tests.json")
/Users/Sites/Laravel/lms/vendor/crestapps/laravel-code-generator/src/Models/Resource.php:549
2 CrestApps\CodeGenerator\Models\Resource::fromFile("tests.json", "CrestApps")
/Users/Sites/Laravel/lms/vendor/crestapps/laravel-code-generator/src/Commands/Framework/CreateScaffoldCommand.php:70
Please use the argument -v to see more details.
I'm getting a similar output when trying to create resources from a database table. I'm using the php artisan resource-file:from-database [model-name] command.
I read online that it may have to do with the Laravel storage folder not having the correct permissions but I've tried that and it didn't work. Cleared and config the cache, composer dump-autoload, etc... But nothing has worked.
I'm also noticing that the generator does not publish the configuration file on your sample video on your website. I have tried to publish the config file using the vendor:publish command but it generates a somewhat empty file, only has this option: 'files_upload_path' => 'uploads'. The folder for the generator located inside the resources folder does not contain a config file.
I did the following commands:
composer global require "laravel/installer=~1.1"
and
set PATH=%PATH%;%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
But when I try to do:
laravel new blog
I get the following error:
Notice: Undefined variable: output in C:\Users\****\AooDara\Roaming\Composer\vendor\laravel\installer\src\NewCommand.php on line 55
Fatal error: Call to a member function writeln() on null in C:\Users\****\AooDara\Roaming\Composer\vendor\laravel\installer\src\NewCommand.php on line 55
Any idea of what went wrong?
Seems like you already have a directory called 'blog' in your application directory. Try creating a laravel app with different name or delete / rename existing 'blog' directory and try again.
for example laravel new helloapp.
However, I think the error showing at the console is a bug of laravel new command. I could see the error at the console when I tried to create a app with same name again from same directory.
The error not exists now. Try creating other application.
I have an existing website up and running, and now I want to add a REST interface to it in an api subdirectory. I'm not able to get this to work with versioning. I installed like so (no errors):
$ php ~/bin/composer.phar create-project laravel/database --prefer-dist api
$ cd api
$ php ~/bin/composer.phar require restler/framework 3.0.0-RC6
Then I uncommented the lines in public/index.php related to Restler and add a new API class that just echos a string. If I run this via php artisan serve and look at it through the localhost URL, then the method works.
Now I want to enable versioning, so I added these lines to public/index.php
use Luracast\Restler\Defaults;
Defaults::$useUrlBasedVersioning = true;
And in app/controllers I created a v1 directory and moved Test.php into that. I also added a namespace directive to the file of the format namespace A\B\v1
When I restart the artisan server and query the API, I get a 404 error. I've tried as both http://localhost:8000/Test and http://localhost:8000/v1/Test
What have I forgotten to do?
Here is how I made it to work. Note the folder where I placed the api class file.
in index.php
use Luracast\Restler\Restler;
use Luracast\Restler\Defaults;
Defaults::$useUrlBasedVersioning = true;
$r = new Restler();
$r->addAPIClass('A\B\Test');
Test.php kept in app/controllers/A/B/v1/Test.php
<?php namespace A\B\v1;
class Test
{
public function get()
{
return 'working';
}
}
Both http://localhost:8000/v1/test and http://localhost:8000/test return "working"