Composer connection - laravel

I'm trying to make laravel project with composer with bellow cmd cod:
composer create-project laravel/laravel laravel-santcum-api
but I get error like this:
[Composer\Downloader\TransportException]
curl error 7 while downloading https://repo.packagist.org/p2/laravel/laravel.json: Failed to connect to 127.0.0.1 p
ort 1797: Connection refused
Also I'm tried with proxy and without proxy but I give the same error in both.

I found answer:
I'm in first installation of Composer added a variable named http_proxy to my environment. The value of http_proxy is what you see in that input.
All you need to do is delete that variable from the environment:

In windows Go to Enviroment Variable and remove "http_proxy" from List and reset terminal.

Related

DigitOcean - laravel 8 deployment through Github (error 500)

I deployed the laravel app to digitalocean:
but I don't understand why is it showing error 500??
I connected a github repo to deploy it to digitalocean.
1- I set the build commands to: composer install
2- environment variables are set: APP_NAME, APP_URL, APP_KEY, DATABASE_URL, APP_DEBUG
This is how the repo looks (private)
What seems to be the issue??
I just did check the repo and it seems the vendors folder not there and your build steps look like a typo issue so please run below command
composer install
Still you face the issue then refer the laravel logs for that what went wrong
you also dont have a .env file
maybe copy the .env.example to .env
perhaps follow the instructions on the laravel site for the version you are using.
in your question, you have spelt 'install' incorrectly
turns out there were typos of lower and upper cases in controllers according to the laravel log.
I fixed them and now the site is running. It's weird that these typos didn't trigger erorrs locally..
All You have to do is configure the .env file if u have a .example.env edit the file to .env if u dont have it just try to create one or clone one from another project and do composer install but don't forget to generate a key with php artisan key:generate in the end

Laravel installation Unable to use a proxy: malformed http_proxy url

I am facing this problem when I try to install Laravel on my Windows machine; how can I solve this problem?
Changed current directory to C:/Users/masab/AppData/Roaming/Composer
[ComposerDownloaderTransportException] Unable to use a proxy: malformed http_proxy url
require [–dev] [–dry-run] [–prefer-source] [–prefer-dist] [–fixed] [–no-suggest] [–no-progress] [–no-update] [–no-install] [–no-scripts] [–update-no-dev] [-w|–update-with-dependencies] [-W|–update-with-all-dependencies] [–with-dependencies] [–with-all-dependencies] [–ignore-platform-req IGNORE-PLATFORM-REQ] [–ignore-platform-reqs] [–prefer-stable] [–prefer-lowest] [–sort-packages] [-o|–optimize-autoloader] [-a|–classmap-authoritative] [–apcu-autoloader] [–apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [–] []…
I'm also facing this error for below command on my Windows system for install laravel.
composer global require laravel/installer
This is global command you can run this from any path on CMD ( command prompt )
but after install wamp or xampp server then http_proxy environment veritable created in your administatory system
Control Panel -> System -> Advanced system settings -> Environment Veriables -> http_proxy
Method 1: Delete http_proxy Veriable and run again the same command from any path. then its works fine.
OR
Method 2: keep the http_proxy Veriable as it is. and open your project directory on CMD ( command prompt ) and run laravel/installer command in your project directory.
My project example : D:>cd wamp\www\laraveldemo
after this enter your command and run it.
This could be because you clicked on HTTP proxy and set the wrong value while installing your composer.
To solve this bug, go to the system environment file (Simply type env in your search and open). Once you open it, you'll find an HTTP option, click on it and delete it. After this, restart your System and reinstall Composer. This time, do not select the HTTP proxy.
Otherwise, set the correct value to the HTTP proxy.
After installation, try rerunning your laravel command and the problem will be solved. Goodluck

Unable to run migration via artisan command

I have a Laravel 7 project and pushed it to a live server for production but I can't run migration successfully. I always get an error 'access denied' error.
I can confirm that the command sees the .env file and the connection details are all correct. When I ssh into the server and run mysql command using same parameters saved in the .env file, connection is successful. Adding the details into workbench and SequelPro also works so I am not sure why php artisan migrate doesn't work
Run the following command:
php artisan tinker
Tinker is Laravel's own repl.
It will prompt you to enter the commands. Here you can check and print the value of the environment variables by entering string inside env method.
>>> env('DB_DATABASE')
and so on for the other DB parameters.
Hope this helps.
For more help you can check out the official Github repository of tinker:
https://github.com/laravel/tinker

composer create-project from self-hosted GitLab instance

I'm trying to use the composer create-project vendor/name --repository=https://my.self-hosted-gitlab-instance.com/repository.git command to create project.
When I run the command I first have to put my credentials :
Authentication required (my.self-hosted-gitlab-instance.com):
Username: myusername
Password:
I enter the correct credentials but then I have :
[Composer\Downloader\TransportException]
Invalid credentials for 'https://my.self-hosted-gitlab-instance.com/myrepository.git/packages.json', aborting.
If you use URL for --repository value it will be treated as repository with type composer. If you want to use different type, you need to pass JSON with full repository configuration:
composer create-project vendor/name --repository='{"type": "vcs","url": "https://my.self-hosted-gitlab-instance.com/myrepository.git"}'
or
composer create-project vendor/name --repository='{"type": "gitlab","url": "https://my.self-hosted-gitlab-instance.com/myrepository.git"}'
--repository: Provide a custom repository to search for the package, which will be used instead of packagist. Can be either an
HTTP URL pointing to a composer repository, a path to a local
packages.json file, or a JSON string which similar to what the
repositories key accepts.
https://getcomposer.org/doc/03-cli.md#create-project

wp-cli: unable to run phpunit on MAMP

I'm following the plugin test setup/install instructions. I got wp scaffold plugin-tests my-plugin to run. But then at the next step when I try to run bash bin/install-wp-tests.sh wordpress_test root '' localhost latest I get the following error:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to MySQL server on 'localhost' (61)'
Check that mysqld is running on localhost and that the port is 3306.
You can check this by doing 'telnet localhost 3306'
My local Wordpress site is running with MAMP (which is working). I'm not sure if that's relevant for the install script since I think it's creating a temporary DB to run the tests... Does it matter if it uses the built-in OSX mysql or MAMP's MySQL?
Here's the output from wp --info
$ ./vendor/wp-cli/wp-cli/bin/wp --info
PHP binary: /Applications/MAMP/bin/php/php5.6.10/bin/php
PHP version: 5.6.10
php.ini used: /Applications/MAMP/bin/php/php5.6.10/conf/php.ini
WP-CLI root dir: /Applications/MAMP/htdocs/pipeline/wp-content/plugins/wp-github-pipeline/vendor/wp-cli/wp-cli
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 0.19.2
Update 2
I figured out that originally MySQL wasn't installed... that's why I couldn't connect! But now it is. I ran the install script, and this works...
$ ./vendor/wp-cli/wp-cli/bin/wp db tables
wp_users
wp_usermeta
wp_posts
wp_comments
wp_links
wp_options
wp_postmeta
wp_terms
wp_term_taxonomy
wp_term_relationships
wp_commentmeta
But when I run phpunit I get this:
$ phpunit
PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452
PHP Stack trace:
PHP 1. {main}() /private/tmp/wordpress-tests-lib/includes/install.php:0
PHP 2. require_once() /private/tmp/wordpress-tests-lib/includes/install.php:21
PHP 3. require_wp_db() /private/tmp/wordpress/wp-settings.php:79
PHP 4. wpdb->__construct() /private/tmp/wordpress/wp-includes/load.php:350
PHP 5. wpdb->db_connect() /private/tmp/wordpress/wp-includes/wp-db.php:649
PHP 6. mysqli_real_connect() /private/tmp/wordpress/wp-includes/wp-db.php:1452
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452
Part of my problem is that I'm not clear on whether wp-cli should be running entirely on native (cli) PHP/Mysql, or MAMP's PHP/Mysql, or some combination of both.
Update 4
I'm pretty sure the final problem is that phpunit needs to be installed in MAMP, but I'm running it from OSX...
$which phpunit
/usr/bin/phpunit
Mentioned in this gist.
Update 6
It turns out you can no longer install phpunit using pear. So I added it as a composer dependency under require-dev, but when I run that version I get the same error!
$ ./vendor/phpunit/phpunit/phpunit
PHP Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: NO) in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452
PHP Stack trace:
PHP 1. {main}() /private/tmp/wordpress-tests-lib/includes/install.php:0
PHP 2. require_once() /private/tmp/wordpress-tests-lib/includes/install.php:21
PHP 3. require_wp_db() /private/tmp/wordpress/wp-settings.php:79
PHP 4. wpdb->__construct() /private/tmp/wordpress/wp-includes/load.php:350
PHP 5. wpdb->db_connect() /private/tmp/wordpress/wp-includes/wp-db.php:649
PHP 6. mysqli_real_connect() /private/tmp/wordpress/wp-includes/wp-db.php:1452
Warning: mysqli_real_connect(): (HY000/1045): Access denied for user 'root'#'localhost' (using password: NO) in /private/tmp/wordpress/wp-includes/wp-db.php on line 1452
I even added it to my path to be sure...
$ which phpunit
/Applications/MAMP/htdocs/pipeline/wp-content/plugins/wp-github-pipeline/vendor/phpunit/phpunit/phpunit
Update 7
After reading the comments at the bottom of this blog post, I see that the install script was referencing the OSX version of mysqladmin. I'm not sure if this matters, but I prepended MAMPs version in the path, and re-ran the install script. It seems to install the Wordpress files in /tmp/ anyway. Same error when I run phpunit
If you are using MAMP, issue may be relevant to your MySQL Server settings. Make sure to check Allow network access option in MAMP settings:
Update 1
Create phpinfo.php file in your root directory (usually /Applications/MAMP/htdocs for MAMP). Paste the following content:
<?php phpinfo() ?>
Then check the Loaded Configuration File property. Open it using nano or other text editor in terminal. Then find and change this 3 propertiespdo_mysql.default_socket, mysql.default_socket, mysqli.default_socket to your socket file.
Referenced from http://maccrazy.com/lion-upgrade-killed-my-php-site-and-how-i-fixed-it
I finally got phpunit to run!!
I couldn't find this documented anywhere...
At some point during the installation process, Wordpress core files are installed in /tmp/wordpress/. That Wordpress installation has it's own wp-config.php file which had incorrect values. When I corrected those values to match the wp-config.php of my site, phpunit worked without problems!
I'm not sure how this happened, but my theory is that the first time I ran the install script with the wrong credentials. But later I corrected them (I re-ran the install script several times). But I think the install script didn't overwrite the original files.
+400 to #Nikita Zernov for so much help!
Normally if you ftp or telnet to localhost you'll get conection refused, if you want to fix the error change your httpd.conf to ServerName localhost
Also if you want to do remote login try enable remote login by going to
System Preferences -> Sharing -> Remote Login box (check it).
For MySQL Problem
Make sure ‘skip-networking’ is commented out in configuration file(in this case /opt/local/etc/mysql55/my.conf) or when starting mysql server, it does’t start with ‘–skip-networking’
In skip-networking mode, the mysql instance doesn’t “listen for TCP/IP connections at all. All interaction with mysqld must be made using named pipes or shared memory (on Windows) or Unix socket files (on Unix)” from MySql Docs
I hope it help.

Resources