Jump to content

Using Composer


Alpine418
 Share

Recommended Posts

Hi.

I've stopped using PW end of last year and shut off all my websites. Until then I could add a custom composer.json in the root dir of my PW installations. But now I'm building a new website with PW and just saw in the root dir of the latest blank installation a composer.json of @ryan.

How should I handle my custom composer settings like PSR-4 autoloading? Can I just customize and add my custom setting in the already existing composer.json like this (check the few latest lines in code below) or are there better practises?

{
  "name": "processwire/processwire",
  "type": "library",
  "description": "ProcessWire CMS/CMF",
  "keywords": [ "processwire", "cms","cmf", "content management system" ],
  "license": "MPL-2.0",
  "homepage": "https://processwire.com",
  "authors": [
    {
      "name": "Ryan Cramer",
      "email": "ryan@processwire.com",
      "homepage": "https://processwire.com",
      "role": "Developer"
    }
  ],
  "require": {
    "php": ">=5.5",
    "ext-gd": "*"
  },
  "autoload": {
    "files": [ 
		"wire/core/ProcessWire.php" 
		"site/my-custom-functions.php"
	],
	"psr-4": {
		"My\\Custom\\": "site/classes"
	},
  }
}

Thanks for your support!

Link to comment
Share on other sites

Hello,

Yes this is where I manage my namespaces and dependencies and it works fine.

"autoload": {
    "files": [
      "wire/core/ProcessWire.php"
    ],
    "psr-4": {
      "Rfro\\Rfrorga\\ProcessWire\\": "site/templates/",
      "ProcessWire\\": "site/classes/",
      "Rfro\\Rfrorga\\WebApi\\": "webApi/",
      "Rfro\\Rfrorga\\Cron\\": "cron/"
    }
  },
  "require-dev": {
    "phpunit/phpunit": "9.5.28",
    "dbrekelmans/bdi": "^1.0"
  },
  "autoload-dev": {
    "psr-4": {
      "Rfro\\Rfrorga\\ProcessWire\\": "site/src-tests/"
    }
  },

 

  • Like 1
Link to comment
Share on other sites

To be honest I'm not an expert with composer, I did some research to configure properly PHP and found this way. It's working locally, working on production server, PhpStorm is not complying and generates the corresponding namespaces when I create a class... so I think this is good. 🙂

Edited by da²
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...