There's a lot of similar responses to this question, but none of them fully touch on the root cause. [Sebastian Schmid's][1] comment on the original post touches on it but not fully. Here's my take as of 2018-11-06:
**Root Cause**
When you try to upload a plugin through the WordPress admin interface, WordPress will make a call over to a function called "get_filesystem_method()" (ref: [/wp-admin/includes/file.php:1549][2]). This routine will attempt to write a file to the location in question (in this case the plugin directory). It can of course fail here immediately if file permissions aren't setup right to allow the WordPress user (think the user identity executing the php) to write the file to the location in question.
If the file can be created, this function then detects the file owner of the temporary file, along with the file owner of the function's current file (ref: [/wp-admin/includes/file.php:1572][3]) and compares the two. If they match then, in WordPress's words, "WordPress is creating files as the same owner as the WordPress files, this means it's safe to modify & create new files via PHP" and your plugin is uploaded successfully without the FTP Credentials prompt. If they don't match, you get the FTP Credentials prompt.
**Fixes**
1. Ensure the plugin directory is writable by the identity running your php process.
2. Ensure the identity that is running your php process is the file owner for either:
a) All WordPress application files, or... <br/>
b) At the very least the /wp-admin/includes/file.php file
**Final Comments**
I'm not overly keen on specifically applying file ownership to the file.php to work around this issue (it feels a tad hacky to say the least!). It seems to me at this point that the WordPress code base is leaning towards having us execute the PHP process under the same user principal as the file owner for the WordPress application files. I would welcome some comments from the community on this.
[1]:
[To see links please register here]
[2]:
[To see links please register here]
[3]:
[To see links please register here]