install Laravel on share folder - php

We have a appserver3 over LAN, means there is folder in remote server and I just map that folder in my my compurt and suppose it got the drive letter G. now when I excute the following
php artisan migrate --package=cartalyst/sentry
but it try to install db in my localhost. But I want to db operation in appserver3. please help me

I assume you have the web server and database up on your appserver3. You could add a new set of config files for your "appserver3" machine, and make sure the db host points to the appserver3's ip address. Something like this:
app/config/appserver3/database.php:
'connections' => array(
...
'host' => 'your appserver3 ip address',
...
)
Then you can run artisan command and specify the environment:
php artisan migrate --package=cartalyst/sentry --env=appserver3

Related

Laravel cannot find public dir

I worked on a team and then clone the laravel/php codes from our repository. When I serve the laravel on localhost, it cannot find all the file inside the public directory and throw an error on the terminal:
[404]: GET /public/css/style.css - No such file or directory
Many answers to similar issues advise me to change the codes in the blade.php file. The problem is that I can't edit the blade.php because it works fine on other team members even though we have the same ubuntu, PHP, and laravel version and .env file.
What I have tried:
Run composer install and composer update
Try different browsers such as firefox and chromium-based browsers
Run php artisan storage:link
Restart apache2
Run npm install and npm run dev
I think there is some package or something missing.
List of paths I get from dd($__data):
"path" => "/project-directory/project-name/app"
"path.base" => "/project-directory/project-name"
"path.lang" => "/project-directory/project-name/resources/lang"
"path.config" => "/project-directory/project-name/config"
"path.public" => "/project-directory/project-name/public"
"path.storage" => "/project-directory/project-name/storage"
"path.database" => "/project-directory/project-name/database"
"path.resources" => "/project-directory/project-name/resources"
"path.bootstrap" => "/project-directory/project-name/bootstrap"
Have you tried?
php artisan storage:link
You need first run
php artisan storage:link
For more details check https://laravel.com/docs/8.x/filesystem
Then you must be check your .env values.
Is correctly APP_URL=
Also in your exception is strange
/public/.../...
Reason is wrong configuration.
First check your .env values like
APP_URL=...
FILESYSTEM_DRIVER=public
then check config/filesystems.php

Connecting laravel to postgres db

I am working on a project where I need to connect Laravel to a postgres db. First time doing this, in the past just used mysql. I am getting this error PDOException::("SQLSTATE[08006] [7] FATAL: no pg_hba.conf entry for host when I try to run php artisan migrate. I am on a mac so I used brew install postgresql. This is a db that already has tables in it.
In my .env file I changed my db to
DB_CONNECTION=pgsql
DB_HOST=<host name>
DB_PORT=5432
DB_DATABASE=<db name>
DB_USERNAME=<user name>
DB_PASSWORD=<password>
What else am I missing?
It seems like your config is missing in pg_hba.conf file.
Suppose you are on localhost, have you tried adding host all all 0.0.0.0/0 md5 entry in your pg_hba.conf? Remember to restart your postgresql services after that.

Envoy and connecting via ssh with username with capitals

I recently installed laravel envoy task runner, when I try to run a task with command envoy run deploy I get the following error:
GabotronES#gabriel-ubuntu-1:/var/www/dtcburger.es$ envoy run deploy
Are you sure you want to run the [echo] task? [y/N]: y
[GabotronES:206.189.X.XX]: ssh: Could not resolve hostname gabotrones:206.189.X.XX: Name or service not known
[✗] This task did not complete successfully on one of your servers.
It says it can't resolve hostname gabotrones but my ubuntu user is GabotronES, in my Envoy.blade.php I have also user GabotronES in #servers directive, is this because envoy doesn't allow username with capitals to connect via ssh?
#servers(['web' => 'GabotronES:206.189.X.XX'])
*censored my IP just in case
I don't think the capitals are the issue.
Please try this syntax:
#servers(['web' => 'GabotronES#206.189.X.XX'])
You can also try to connect directly from the command line, to check if things work as expected.

Php Artisan serve command not serving Laravel 5.8

I installed a new Laravel instance, using version 5.8. Along the way, I found out that I can't serve the project using the normal Laravel php artisan serve command.
After some research with lots of trial and error, I came across this answer on StackOverflow that helped me with this method php -S localhost:8000 -t public/ with which I followed to change the port to port 9000, and it served the project perfectly.
Now my question is how can I go about getting the artisan command to be the default command to serve and rum my Laravel 5.8 on Windows just like before? I don't know anything about configuring Laravel core commands.
I tried this command.
php -S 127.0.0.1:9000 -t public/
after running this its works fine.
and also php artisan serve command works fine.
hope it will help.
You should open ServeCommand.php file (Illuminate\Console) and then change getOptions method
protected function getOptions()
{
$host = env('SERVE_HOST', '127.0.0.1');
$port = env('SERVE_PORT', 8080);
return [
['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', $host],
['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', $port],
];
}
when create a SERVE_HOST and SERVE_PORT in your .env file
SERVE_HOST=localhost
SERVE_PORT=9000
source
You can run the project on port 80. If you are using Linux simply run the command from the embedded server with root user permission.
Example: sudo php -S localhost: 80 -t public /

Make Laravel artisan play with vagrant from localhost

When I ssh into my local vagrant machine I can execute all artisan commands. Hower outside of it, any commands that needs database access such as artisan migrate gives Access denied for user 'root'#'localhost'. If it is possible, how can I use artisan without having to log in to the vagrant machine?
I would also like to do for example Artisian::call('migrate') for example during testing. But that gives the same error.
The reason for the access denied error is that mysql by default limits access to databases to the local machine. It is possible to open up for remote connections as described here, but it wouldn't be a good idea for production environments.
A better way is to add aliases for the commands you want as described here.
For doing calls to artisan etc in code, Laravel has a built in way of running commands on remote servers. First add connection information to the app/config/remote.php file. For vagrant it should look something like this:
'connections' => array(
'production' => array(
'host' => 'localhost',
'username' => 'vagrant',
'password' => 'vagrant',
'key' => '',
'keyphrase' => '',
'root' => '/vagrant',
),
),
Then execute artisan migrate like this:
SSH::run(array('cd /vagrant', 'php artisan migrate'));
You can do more advanced things as well. Here is the documentation.

Categories