So, I have tried 4 different ways of doing this, none of them worked.
There's a 3rd party server that I can create and delete files on via Filezilla. This was for testing purposes however.
There's a script on my Laravel application that'll run once a day, create a few XML files and those need to automagically transfer to that same server.
When I create an ftp filesystem I get the error "ftp_rawlist(): php_connect_nonb() failed: Operation now in progress (115)" after a timeout.
When I try PHP's ftp_put or ftp_fput I get the error "ftp_put(): php_connect_nonb() failed: Operation now in progress (115)" (or ftp_fput, same error).
When I try PHP's fwrite with the ftp as a destination I get the error "failed to open stream: operation failed". This also fails in the browser.
I have made sure credentials are correct. I've copy/pasted them from the working Filezilla connection details.
Filesystem code:
'ftp' => [
'driver' => 'ftp',
'host' => env('FTP_HOST'),
'username' => env('FTP_USERNAME'),
'password' => env('FTP_PASSWORD'),
'root' => '/Production',
'ssl' => true,
'ignorePassiveAddress' => true,
],
I know about the server behind NAT problem, but it won't accept my changes to use original address in filesystems. I've cleared cache, and config and fed the hamsters, but nothing changes.
I'm honestly at the end of my knowledge right now. And asking the 3rd party to change their configuration/settings isn't an option. This server is one of many and they're all exactly the same, but different clients. They might help me by providing the logs on their end, but that's about it.
The only other that I see which could be a difference is that I'm running this code from command line (ie, as if it's run via cron). Not sure if that causes problems with connecting and creating files on a remote server. I'm not that experienced with writing Laravel commands.
Any help would be greatly appreciated.
Ok.
Ok. Inside the configuration file like this:
'ftp' => [
'driver' => 'ftp',
'host' => 'ftp.example.com',
'username' => 'your-username',
'password' => 'your-password',
'passive' => 'false',
'ignorePassiveAddress' => true,
'port' => 21,
]
add file 'test.pdf' inside the ftp
simply run
$contents = \Storage::disk('ftp')->exists('test.pdf');
dd( $contents );
and it works.
i work with laravel 5.2, i have built a small app i just want to upload it to shared hosting
i tried with 000webhost and byethost and i got problems like
Wrong COM_STMT_PREPARE response size. Received 7
Whoops, looks like something went wrong.(in two lines without explanation the problem)
this problem is in the database engine of the free shared hosting
for example in 000webhost:
edit config/database.php:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
//.......
'options' => [PDO::ATTR_EMULATE_PREPARES => true,]
],
Following this Setup Laravel 5 Application without command-line access
I have a question about second criteria.
I'm using free hosting and I have the "htdocs" folder that is basically my "public_html"(I think so), because the displayed "index.html" file that comes by default is in it. So, following the second criteria from the above topic, I need to change the "htdocs" for "laravel_folder/public", correct? If so, how can I do this by .htaccess, please?
I just deployed a Laravel 5.7 app on 000webhost which is free hosting website.
First of all, you have to generate a key for your app and erase the cache.
Use the command: php artisan key: generate
Then php artisan config: clear
and finally php artisan cache: clear.
Now you take the folder / root directory or where you have your app, you have to compress it in a zip file.
Create a new folder in the root of the File Manager, for example a folder called App.
Upload the zip file to the App directory on https://files.000webhost.com/ by clicking on the "Upload Files" button on top right.
When it's done, you have to click on the zip file and select "Extract". Also make sure to write "." to extract the contents directly into App.
Make sure all the files are in App just like that.
Move all the files in the public folder (App/public) to the public_html folder.
Now that we have everything, we are going to configure what is necessary.
A previous step is to create a new database for them you will have to go to the section "Manage databases" and create one. Then manage the base in phpmyadmin and import the database of your project / application.
Once this step is completed, the following is:
1.-Configure index.php, in the directory public_html/index.php, you must add the App folder to the addresses of autoload.php and app.php.
Change require __DIR__.'/../vendor/autoload.php';
by require __DIR__.'/../App/vendor/autoload.php';
Change $app = require_once __DIR__.'/../bootstrap/app.php';
by $app = require_once __DIR__.'/../App/bootstrap/app.php';
Below this line add the following
$app->bind('path.public', function() {
return base_path().'/public_html';
});
2.- Go to the .env file and modify the host, the database, the user and the password with the values of the database that we made in the previous step. Copy the APP_KEY also, we will use it later.
3.- In config/app.php, find the line : 'debug' => env('APP_DEBUG', false),
and change the value to true :
'debug' => env('APP_DEBUG', true),
find tehe line: 'key' => env('APP_KEY'),
and add a comma followed by base64_decode ('copy the key that was in the .env file here').
For example:
'key' => env('APP_KEY',base64_decode('AsAAAAA+AWERSDFT4Y123Ywpj123PNaleLdPwcd0000=')),
4.- In the same directory but in the database.php file (config/database.php),
find:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
Add this line after host: 'options' => [PDO::ATTR_EMULATE_PREPARES => true,],
Modify the host, database, user, and password with the values in the database as in step 1.
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'options' => [PDO::ATTR_EMULATE_PREPARES => true,],
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'databaseNamehere'),
'username' => env('DB_USERNAME', 'userNamehere'),
'password' => env('DB_PASSWORD', 'passwordHere'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
Now we can go to the address of the server and you can see your app running correctly.
I hope it helps you, greetings.
No, there you need to copy all the files inside the public folder (~/MyAwesomeProject/public/) into the public_html folder (~/public_html).
This blog article will help you to deploy Laravel project on Shared Hosting Server Using cPanel Options:
Laravel: Deploy Laravel Projects On Shared Hosting
From memory of working on shared hosting this is going to be difficult. What you could do, assuming FTP access, is upload everything to your root level, and then in the Laravel configurations you can change the name of your public directory, so to htdocs
Though I think you might struggle with some of Laravels features without having command line access
I'm assuming you're developing for a production environment, if so you can get a cheap VPS or Droplet where you could effectively utilise Laravel alternatively VirtualBox or something for development would work well
Laravel quite heavily relies on Artisan (their Cli interface) as well as various tools within there (such as Migrate which works with Eloquent to deploy tables) so I think you might struggling using this on a shared box.
The reason for all of this reliance is because Laravel was built for Enterprise usage, where generally shared boxes aren't utilised.
I think there are some hosts out there who will give you command line access, however.
If you need to use a different MVC framework without having command line access CodeIgniter is a good one
I just deployed a Laravel app on 000webhost which is free hosting website. I faced some problems, but here's how I solved them:
1- Go to your app's root directory (where app, public, resources and other directories exist) and zip them all into a one zip file (it is important for it to be zip not rar).
2- Upload the zip file to the public_html directory on https://files.000webhost.com/ by clicking on the "Upload Files" button on top right.
3- It will take some time to upload. When it's done, you have to click on the zip file and select "Extract". Also make sure to write "." to extract the contents directly into public_html.
4- Now if you go to the URL 000webhost provides for your site, let's call it $url, then add /public to it which is where your entry point index.php file resides, you'd suppose to see the homepage of your site: $url/public . But you won't.
5- For some reason I didn't understand, the .env file which is a shortcut of your config files in the config directory could not be read. So, you'll have to update your config files, mainly config/app.php and config/database.php.
6- The first problem you'll have is the key issue. In config/app.php, find the line :
'key' => env('APP_KEY'),
and replace env('APP_KEY') with the actual key that you see in you .env file (in case it is empty for you, you'll have to generate a key by sending the command on your computer php artisan key:generate)
7- If you are using a database (such as MySQL), then you'll have to also go to config/database.php and replace all values of env with actual values, mainly these values :
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
P.S: there should be NO env variable whatsoever. Remove all envvariables that you don't use and replace the rest with real values.
I couldn't figure out a way to do virtual host for the free version (maybe you can configure a vhost for the paid version..). So, you'll have to remember that the url provided by 000webhost should be appended by /public (I say this again because you might have to change your navbar links as well by applying this logic).
And voila! It should work now. Well, in case you face any more issues, there's 2 things you can really do to figure them out:
1- In config/app.php, change the debug value from false to true to see the errors instead of a "whoops" message :
'debug' => env('APP_DEBUG', true),
2- You can check the storage/logs/laravel.log file to see the errors you are getting.
Good luck!
I want to use the ftpd Adapter in Laravel to access a Synology NAS, which seems to need this specific adapter https://github.com/thephpleague/flysystem/issues/305, but I get the error
Driver [Ftpd] is not supported.
The file is there:
vendor/league/flysystem/src/Adapter/Ftpd.php
Do I have to register anything that I can use it?
I tried to use it in filesystems.php like this
'diskstation' => [
'driver' => 'Ftpd',
'host' => 'ftp.domain.com',
'username' => '****',
'password' => '****',
// Optional FTP Settings...
'port' => 21,
'root' => '',
'passive' => true,
'ssl' => false,
'timeout' => 10,
],
It looks like laravel does not support ftpd out of the box as you can see here:
https://github.com/laravel/framework/blob/5.4/src/Illuminate/Filesystem/FilesystemManager.php#L13
It imports a few of the Flysystem drivers, but not the ftpd one.
However you can create custom drivers like is shown here in the docs. The ftpd driver is already build for flysystem so you just need to import it in laravel via this method.
I've been attempting to set up a version of my website on my computer so that I stop making live updates on my website. The website runs on a PHP based CMS.
I posted a question earlier: mysql connect - Moving my website to a local host
The question was about mysql-connect - the outcome was that I connected my database to my localhost as opposed to the current live host.
Now, the local version of my site loads except all styling is gone and the nav links do not work. I suspect the answer may be to do with the same file I edited in the question above: application/config/database.php
Here is what the code looked like originally:
$config['default'] = array(
'benchmark' => TRUE,
'persistent' => FALSE,
'connection' => array(
'type' => 'mysql',
'user' => 'mywebsite',
'pass' => 'somestringoftext',
'host' => 'mywebsitecom.fatcowmysql.com',
'port' => FALSE,
'socket' => FALSE,
'database' => 'mywebsiteDB4',
Then I changed it to this:
$config['default'] = array(
'benchmark' => TRUE,
'persistent' => FALSE,
'connection' => array(
'type' => 'mysql',
'user' => 'root',
'pass' => '',// Since it's on local host there is no password right now
'host' => 'localhost',
'port' => FALSE,
'socket' => FALSE,
'database' => 'mywebsite',//this is what I called the DB I created and imported to in PHPmyadmin
It may be that this all looks correct and the issue lies elsewhere. I have a suspicion that it could be to do with the .htaccess file as, when I initially set up the site, I had issues with that, except all I had to do was set permissions. Thing is, the way the local version appears right now is very similar to how it looked when the .htaccess file was not "working".
I realize that I've just dropped a bunch of code and said "help"! I'm really stuck on where to look next. If anyone does have any ideas I'd be grateful to hear them. If any further info could help anyone with suspect ideas please let me know and I'l update.
If site loads and you can see at page data taken from database, it means, what you DB connection is OK.
Since you can't see styling and menu not works, it means what you .JS/.CSS files not loaded correctly from you local server.
You can use addon FireFox called FireBug and here "Net" tab, to see which files loaded correctly and which not. For not loaded files you will need or change path to include it in you HTML file or change files location in you local filesystem