Tuesday, February 22, 2022

[FIXED] Is there a one line cmd to install wordpress locally with composer?

Issue

Using laracasts I was able to install a new Laravel project by typing in laravel new project-name into the console and it will install a new Laravel install. I was looking to have the same functionality with WordPress. I found a few tutorials that mentioned that said to install WordPress with composer I would have to put a composer.json file in the folder I want to install WordPress in with

{   "require": {
    "johnpbloch/wordpress": "*"   } }

I'm trying to figure out a way to set it up so I can just type in wordpress new project-name and composer will create a folder using that name with a blank WordPress install. I'm guessing maybe I would use an alias?


Solution

laravel new project-name is probably a shortcut for composer create-project --prefer-dist laravel/laravel project-name. It basically uses laravel/laravel package as a project template and initializes your app using it as a starter. If you want similar functionality for WordPress, you need to find project template for Wordpress. You may try Bedrock as am example, but there are also other starters for WordPress:

composer create-project roots/bedrock project-name

If you really want to use wordpress new syntax, you should probably create custom wordpress command which will call composer create-project internally. But I would not recommend that, it does not give much benefits, just hides what is really happening.



Answered By - rob006

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.