I am trying to integrate elfinder in Laravel 4.2 using barryvdh/laravel-elfinder package. This works perfectly for the local file system. I need to integrate it with AWS S3. For that I have used flysystem driver. In this packages config file, I have defined root like this
'roots' => [
[
'driver' => 'Flysystem',
'adapter' => new \League\Flysystem\AwsS3v2\AwsS3Adapter( \Aws\S3\S3Client::factory(array(
'key' => 'key',
'secret' => 'secret',
'region' => 'us-east-1',
)), 'bucket_name', '')
]
],
But this doesnt seem to work. I get this error {"error":["errConf","errNoVolumes"]}
Have anyone successfully done this before. Please help me.
Related
PHP 7.3
Laravel 5.8
Until now I was using Predis for my cache in the Laravel project. Now I want to switch to PhpRedis. I've read it's really simple (just config changes), but I have a lot of problems. I don't know what to begin with, so I'll write all what I know.
My hosting provider claims that PhpRedis is enabled.
The code below executed in a controller (Predis is set) works fine - I receive the set value.
$redis = new \Redis();
$redis->connect( 'socket path', 0 );
$redis->set('test', 'testValue');
print_r( $redis->get('test') );
However, the same code in the raw PHP file executed via SSH returns "Uncaught Error: Class 'Redis' not found in..."
Let's go to changes in config/database.php. Here is my configuration:
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'/*'phpredis'*/),
'cluster' => true,
'options' => [
'cluster' => env('REDIS_CLUSTER', 'predis'/*'redis'*/),
'prefix' => Str::slug(env('APP_NAME'), '_').'_',
'parameters' => ['password' => env('REDIS_PASSWORD', null)],
],
'default' => [
'scheme' => 'unix',
'path' => env('REDIS_HOST'),
'host' => env('REDIS_HOST'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT'),
'database' => env('REDIS_CACHE_DB', 0)
],
(...) // other
],
When I change values to these in comments, my website shows just a blank page - any errors in the mailbox.
Furthermore, when I run for example "php73 artisan config:clear" in the SSH, console returns "Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension." in the Illuminate/Redis/Connectors/PhpRedisConnector.php.
When I change the alias in config/app.php from "Redis" to "RedisManager" and try again it returns
Uncaught Error: Class 'Redis' not found in /path/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:70.
What's going on? How to set Laravel's configuration to use PhpRedis? Maybe it's my hosting provider issue? Thanks in advance for every advice.
If I missed some important code, give me a sign - I will add it.
The PHPRedis libraries are not installed by default in a shared hosting environment, and are generally not part of a PHP installation by default. You would have to ask your host to install these libraries within their shared hosting platform.
We are using Nova package for our admin backend inside our Laravel App. All files and images are stored in the AWS S3 bucket.
After trying to download a file from Nova, the download begins with the name download.json and Server Error message.
Files are stored correctly in S3, I can check it manually, also the path to them inside S3 is correctly stored in the database.
Here is the code we use to create a download field in Nova
->download(function(){
return Storage::disk('s3')->download($this->name);
})
->onlyOnDetail()
$this->name holds the path inside the s3 bucket.
config/filesystems.php is also defined:
'disks' => [
...
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],
Nova documentation did not helped me on this problem. Any input would be really helpful.
UPDATE:
The problem was not in code but in Configuration.
Without changing the configuration the following code did help:
Text::make('File/Document', function() {
$linkToFile = Storage::disk('s3')->temporaryUrl($this->name, now()->addMinutes(1));
return 'Download file';
})
->asHtml(),
Hard to see any issue without seeing the complete function, but make sure your name property $this->name has the same value as your remote file 'key' as shown in your Amazon s3 bucket.
Also, make sure the your .env file is correct and contains the following value:
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_access_key
AWS_DEFAULT_REGION=your_default_region
AWS_BUCKET=your_bucket_name
AWS_URL=your_url #if applicable
Hope this makes sense.
Edit: One more thing, in filesystem.php, this line:
'url' => env('AWS_URL'),
was changed in Laravel 6.x according to this bug and became:
'endpoint' => env('AWS_URL'),
I'm really just looking for an explanation about memecached and laravel. I understand what it does, but can I use my memcached installation with laravel. More specifically:
'memcached' => [
'driver' => 'memcached',
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
'sasl' => [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
I know/will set up the server aspect, and I get what the options do...but persistent_id, a memcached um and pw...what are they? Their uses? etc.. typically laravel is extremely well document but on memcached it says very little (And the little it does, seems to be dated and not based on 5.0 laravel)
Here is explanation from php.net:
By default the Memcached instances are destroyed at the end of the request. To create an instance that persists between requests, use persistent_id to specify a unique ID for the instance. All instances created with the same persistent_id will share the same connection.
http://php.net/manual/en/memcached.construct.php
So for your project just define a unique name for it.
Hope it helps.
I am using filesystem package without problems for upload and download files to rackspace. According to docs on how to obtain the file url I do:
$content = fopen('logo.png', 'r+');
\Storage::disk('disk_temp')->put('logos/logo.png', $content);
$url = \Storage::disk('disk_temp')->url('logos/logos.png');
Works good. But, this url is http:// version. How to obtain the secure version like https:// if I am using rackspace vendor? Here my config:
'disk_temp' => [
'driver' => 'rackspace',
'username' => env('RS_USER'),
'key' => env('RS_API'),
'container' => 'disk_temp',
'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/',
'region' => env('RS_REGION', 'DFW'),
'url_type' => 'publicURL',
],
Years before, I used Open Cloud successfully, obtaining the URL as
$file = \OpenCloud::container('cdn')->uploadObject($filename, $content);
$url = (string) $file->getPublicUrl(UrlType::SSL);
Just to know if possible doing the same from laravel itself. Thank you in advance.
I am developing a laravel 5 project and storing image files using imagine. I would want to store my image files in a folder outside the project's root folder. I am stuck at the moment The external folder where image files are supposed to be stored, I want to make it accessible via a sub-domain something like http://cdn.example.com Looking towards your solutions.
The laravel documentation could give you a helping hand.
Otherwise you could go to config/filesystems.php and add your own custom storage path for both local and production:
return [
'default' => 'custom',
'cloud' => 's3',
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path().'/app',
],
'custom' => [
'driver' => 'custom',
'root' => '../path/to/your/new/storage/folder',
],
's3' => [
'driver' => 's3',
'key' => 'your-key',
'secret' => 'your-secret',
'region' => 'your-region',
'bucket' => 'your-bucket',
],
'rackspace' => [
'driver' => 'rackspace',
'username' => 'your-username',
'key' => 'your-key',
'container' => 'your-container',
'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/',
'region' => 'IAD',
],
],
];
get ur path name from base_path(); function, then from the string add your desired folder location.
suppose ur
base_path() = '/home/user/user-folder/your-laravel-project-folder/'
So ur desired path should be like this
$path = '/home/user/user-folder/your-target-folder/'.$imageName;
make sure u have the writing and reading permission
You can move all or a part of storage folder in any folder of yours in your server. You must put a link from old to new folder.
ln -s new_fodler_path older_folder_path
You can make a new virtual host to serve the new folder path.