autoload.php won't work on my web server - google-api

So I followed the instructions on how to use composer to install google's api client.
When I try to open a file in my web browser that only has this code
<?php
require_once 'vendor/autoload.php';
I get these errors from my hosting provider
[03-Aug-2017 23:46:22 UTC] PHP Warning: require(/home/michmarket/public_html/vendor/composer/../guzzlehttp/psr7/src/functions_include.php): failed to open stream: No such file or directory in /home/michmarket/public_html/vendor/composer/autoload_real.php on line 66
[03-Aug-2017 23:46:22 UTC] PHP Fatal error: require(): Failed opening required '/home/michmarket/public_html/vendor/composer/../guzzlehttp/psr7/src/functions_include.php' (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/michmarket/public_html/vendor/composer/autoload_real.php on line 66
I tried to make sure that all of the files API files up to date by running this in my command prompt.
$ composer require google/apiclient:^2.0
When I do, my command prompt says that all my files are up to date. Any thoughts on why I am still getting errors?

If you can't run
$ composer install
on your web server, then you need to transfer your vendor directory to your web server after running the command on your deployment server.
If your deployment server is your local machine, try to make it match the web server in terms of platform requirements as close as possible (PHP versions, you could be running newer versions locally than on the web server), or refer to https://getcomposer.org/doc/06-config.md#platform:
Lets you fake platform packages (PHP and extensions) so that you can emulate a production env or define your target platform in the config. Example: {"php": "5.4", "ext-something": "4.0"}.
Note You might want to optimize the autoloading as well, take a look at https://getcomposer.org/doc/articles/autoloader-optimization.md#autoloader-optimization.

Related

Running Aurelia without a server in Firefox

I know a lot of 'recent' JS tech require a server to work, but is there a way to run a simple Aurelia hello world without a server installation, just opening index.html and see my hello world app shown in the browser. It works for angular 1.x and many other JavaScript libraries.
Is the System.import mechanism going to force me to use a server ? Or is there a workaround to read local files, I tried the usual hacks but it did not help as I still get Error: [Exception... "File error: Unrecognized path" nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" but the path shown in the error (not pasted here) matches my local path.
The Aurelia starter pack recommends using Firefox to accomplish this goal if you are using the ES2016 starter kit. Firefox is the only browser that supports the use case you are asking about.
For any other browser, you will need to run a server. I recommend using the extremely simple to use http-server that runs on NodeJS.
From within your project directory type the following two commands:
npm install -g http-server
http-server
Then open your browser and navigate to http://localhost:8080 (8080 is http-server's default port. This port can be changed using the -p command line argument.

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.

Upload a Laravel 4.2 project on bytehost

I have uploaded my Laravel 4.2 project (using Filezilla) which is stored in folder name main-Laravel into the htdocs folder on bytehost.when I tried accessing it like this http://bcms.byethost8.com/main-laravel/public/, I an error saying Fatal error: require(): Failed opening required '/home/vol12_4/byethost8.com/b8_16140412/htdocs/main-laravel/bootstrap/../../main-laravel/vendor/autoload.php' (include_path='.:/usr/share/pear/') in /home/vol12_4/byethost8.com/b8_16140412/htdocs/main-laravel/bootstrap/autoload.php on line 17. I did not have this problem when working on my local machine, so what can I do to resolve this problem and thanks in advance.
You will need to do additional setup to get Laravel working on a shared hosting.
Laravel needs composer to get the autoloading right and few other requirements to be run (such as higher PHP version, several PHP extensions & so on).
Here you can find more info:
http://laravel-tricks.com/tricks/setup-laravel-4-in-shared-hosting-with-securing-laravel-base-file

Laravel 4 Workbench not working in Pagodabox

Im developing a library hand in hand with a project I'm working on in L4 and I'm doing it in a Workbench as recommended. I have set the Service Providers etc and it works fine on my local machine. However when I pust to Pagodabox, the console gives me this:
Error Output: PHP Fatal error: Class 'Coderollers\Formidable\FormidableServiceProvider' not found in /var/www/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 123
Clearly, for some reason, on Pagodabox it is looking for my service provider in the vendors folder rather than the workbench folder. Does anyone know why this might be?
For a workbench package to be loaded by Laravel it expects to find an autoload.php file within a vendor directory of your package. You'll need to run composer install from your workbench packages directory to install the package dependencies and have it dump an autoload file.
Once done Laravel will be able to detect and use your package.

Zend Framework 2 Getting Started on WAMP server

I have been trying to follow this tutorial: Tutorial
I can't get past page 2. When I try to run the command:
php composer.phar create-project --repository-url="http://packages.zendframework.com" C:\wamp\www\zendTutorial
I get these messages:
[RuntimeException]...[Composer\Downloader\TransportException]<br>
The "http://packages.zendframework.com/packages.json" file could not be downloaded: failed to open stream: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
I enabled ssl_module in the Apache modules and php_openssl in PHP extensions and a runtime error window popped up which I didn't read because I thought I would restart the server and everything would be okay.
Then I found out I had to create a private/public key pair so I followed this tutorial: tutorial
But I realized I skipped the step where I have to download WSAS (the 3rd application to download just to get this pig to oink) to export my pk from the keystore and I decided to put on the brakes and ask "really?" Is there a shortcut I can take to bypass all this crap so I can start with the tutorial? I've been at this for the past 3 hours and I am so fed up - it's demoralizing.
Note Another way to install the ZendSkeletonApplication is to use github. Go to https://github.com/zendframework/ZendSkeletonApplication ...
Try it this way. Get git and clone the repository from
https://github.com/zendframework/ZendSkeletonApplication.git
To do this, change in console (cmd.exe) to your workspace and type
git clone https://github.com/zendframework/ZendSkeletonApplication.git
It should create a subfolder ZendSkeletonApplication with the skeleton application inside.
Later when you have your skeleton application project you can run composer as described in the tutorial to get the dependencies.

Resources