Using WP-CLI on Windows to Manage Remote WordPress Installation? - wordpress

I'm trying to manage my remote shared hosting WordPress installation via WP-CLI installed on my local Windows machine. So far I have managed to install WP-CLI (The "WP" command is available to run).
But when I try and connect to a remote URL with "wp --http", I get the following messsage:
RESTful WP-CLI needs to be installed. Try 'wp package install wp-cli/restful'
So I run the suggested command and I get:
Composer directory for packages couldn't be created.
I hadn't installed via composer. Instead, I manually instaled PHP and then downloaded the "wp-cli.phar" file. So I tried to install composer on Windows, but couldn't make head or tail of what downloads where. I "think" I managed to install wp-cli, but couldn't see where it had installed the files...and it just didn't work out.
Do you guys know of a more straightforward way to do this?

Concerning the error: Composer directory for packages couldn't be created.
If you did not set the environment variable WP_CLI_PACKAGES_DIR the default is ~/.wp-cli/packages/ which works for Linux but not for Windows.
I set this variable and the command 'wp package install wp-cli/restful' now successfully creates the directory for packages and the composer.json file but still doesn't install wp-cli/restful.
So I used composer directly and it successfully installs wp-cli/restful.
If I use the parameter --http=me.local.com (which matches example in the documentation) I get the error "Couldn't auto-discover WP REST API endpoint from me.local.com.' However, if I change this to --http=me.local.com/wp-json it works. The actual command I used is:
wp --http=me.local.com/wp-json rest post list

Related

Drupal site is broken due to badly installed module

I tried to install Simple OAuth (https://www.drupal.org/project/simple_oauth) module in my drupal site running in a shared Godaddy hosting. My first mistake was not to read the installation guide instructing to install the module by using composer. Instead, I installed the module using the Extend=>install a module link within Drupal. Installing the simple_oauth and enabling the module crashed my site and there is no output from the site.
Then I realised there is something wrong with the installation and checked the error log file. The error logged was:
PHP Fatal error: Interface 'League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface' not found in /home/-----------/public_html/drupal/modules/simple_oauth/src/Repositories/AccessTokenRepository.php on line 10
At that point I realised there is something wrong with the installation and checked the module instructions which states I should use composer to install the module. I tried to solve this problem by redoing the installation from the ssh by using composer and this command:
composer config repositories.drupal composer https://packages.drupal.org/8 && composer require drupal/simple_oauth:^3
Which did not work because GoDaddy shared hosting plan has only 512mb of rams and composer kills the command because of lack of memory.
I tried reading through and understand how Composer works. There were recommendations saying you should never use composer in a production site and you should run it on your computer and copy the composer.lock file which needs much less rams. I created a PHP server using XAMMP on my computer and copied the composer.json file to my computer and run composer update command in my computer. It downloaded the dependencies and stuff on my computer. And feeling I get the hang of it, I copied the composer.lock file in my drupal server, run composer update command and saw composer delete many stuff which I could not undo.
So my questions are: 1- Is there a way of rescuing this drupal site at this point? I deleted many composer dependencies as far as I can understand.
The new error log says: PHP Fatal error: Interface 'Symfony\Component\HttpKernel\HttpKernelInterface' not found in /home/--------/public_html/drupal/core/lib/Drupal/Core/DrupalKernelInterface.php on line 15
2- If not, which is fine as I was just beginning to setup the site. Is it possible for someone to explain the best way of handling this scenario? I mean installing a module using composer in a memory critical place. Or explain how composer works for layman. I read about all the dependency stuff but could not figure out how to use it for this scenario.
Thanks.

Installing WordPress on an AWS instance (not through AWS Marketplace)

I need help installing WordPress on my new Amazon EC2 instance.
I created it and I have SSH and SFTP working through FileZilla (using PuTTY because I'm on Windows 10). I also have my Google domain name pointing to the IPv4 address as well.
How do I install WordPress on my site now? I don't want to install it initially when setting up the instance through the AWS marketplace with bitnami or whatever.
Please follow these steps to install the WordPress in AWS:
Log in to AWS using SSH.
Go to Root Folder (/var/www/html/).
Check whether wp cli is installed or not. If not, please install. The installation guide is here.
Create a folder in the name of the project.
Get into the folder (cd folder name).
Use command wp core download (it will install the latest version).
Use command wp core config --dbname=<dbname> --dbuser=<dbuser> --dbpass=<dbpassword> --dbhost=localhost (it will create wp-config.php file)
Use command wp db create (create database in named as previous command)
Use command wp core install --url=http://<yoursiteurl> --title=<Project Name>--admin_user=<adminuser> --admin_password=<adminpassword> --admin_email="<youremailid>"
It will install WordPress in AWS. We followed the same with successful installation many times. Please find the automated script at GitHub (https://github.com/trisghosh/wordpress-automated-script). Please use the automated one after you complete at least one manual installation.

ignore dev dependencies in php composer

I have developed a composer laravel based project that I need to install on a remote production server. The problem is I have limited permission/ access so my option is to "archive" the package( using composer archive) and unpack on the production.
What folders do I need to archive and how can I ignore the dev dependencies of the package as well as vendor dev dependencies?
composer archive is likely not to help you, because this command creates an archive of a defined version of a package.
You probably want to upload the whole working application, and not only one package. You should create a little script that will create the archive file for you, which should do:
checkout the application from the repository in a new directory
run composer install --no-dev to install all required dependencies without dev-dependencies
optionally delete files that are not necessary on the server, like documentation, the .git folder, and other stuff
create the archive file from all these files
optionally upload that archive to the target server and unarchive there
optionally check basic functions and switch to the new uploaded version on the server

WP-CLI installation over composer

I'm working on a wordpress skeleton for practice. I've got a Composer project and installed the wp-cli/wp-cli dependency.
I want to create and run custom tasks with this wp-cli, for example to download the core of WordPress into this project. This because I'm not putting the core of wordpress into my git repository.
Because I have installed the wp-cli/wp-cli dependency only in my project and not globally over my local machine, I can't run the wp ... commands a normal terminal.
For my own research, I found out that I can use the Command Line Tool Support plugin in my IntelliJ IDE. With this plugin I can use the composer dependency to run commands with the wp-cli. I don't think this is the right solution, because everyone might have a different IDE and/or operating system.
How can I run wp-cli commands over the installation over Composer?
Instead of running commands with /vendor/bin/wp ..... I found out I have to replace the / with a \.
To run commands from this binary, this syntax should be used like:
vendor\bin\wp ...

Install R package from Atlassian Stash

I made an R package which is hosted on my employer's instance of Atlassian Stash. I have been telling other users to clone the repo and then use devtools::install("<path-to-repo>") to install the package.
How can I have users install the package without cloning the repository? Can I do this without hosting the code somewhere more accessible?
Using this solution as a starting point, I discovered that you can use devtools with a Stash ssh url:
devtools::install_git("ssh://git#stash.yourdomain.com:1234/project/repo.git")
That will install from the latest commit on the master branch. You can also install a specific branch:
devtools::install_git("ssh://git#stash.yourdomain.com:1234/project/repo.git", branch="develop")
or tag:
devtools::install_git("ssh://git#stash.yourdomain.com:1234/project/repo.git", branch="v1.0")
(note you don't need the tags/ prefix when using a tag)
This will only work if you have SSH keys for your machine on your Stash account. Using the http clone url will not work, because you can't authenticate properly.

Resources