Saeghe is a difficult name to pronounce. Therefore, Saeghe project has been renamed to phpkg.
This website no longer receives updates.
Please visit phpkg website at phpkg.com
As part of the init command,
Saeghe creates a saeghe.config.json
file for your application.
You can find any configurable option on that file here.
After running the init
command, you should see a saeghe.config.json
file with the following content:
{
"map": [],
"entry-points": [],
"excludes": [],
"executables": [],
"packages-directory": "Packages",
"packages": []
}
Let's dive into each of them separately.
In this config, you can add your desired map for namespaces.
For example, assume you want to map the MyAwesomeApplication
namespace to point to the src
directory.
Then you should define:
{
"map": {
"MyAwesomeApplication": "src"
}
}
Now assume you put your tests in the tests
directory and
you want to use the Tests
namespace to point to the tests
directory. Then you will have:
{
"map": {
"MyAwesomeApplication": "src",
"Tests": "tests"
}
}
You can have as many as you need to map, and it makes sure to resolve all of them in your application.
This config should point to your entry points files.
For example, let's assume you have 2 entry points, one for HTTP requests and one for CLI requests.
For HTTP requests, the file is in {PROJECT_ROOT_DIRECTORY}/public/index.php
and for CLI, the entry file is {PROJECT_ROOT_DIRECTORY}/cli-runner.php
.
in this case, you need to define entry points as follows:
{
"entry-points": [
"public/index.php",
"cli-runner.php"
]
}
The required autoload using class maps for classes gets added in these files.
Normally, all files in all directories in your application gets built.
Sometimes you don't need to have some files or directories in your build directory.
For example, let's say your application contains a node_modules
directory
and a bash file like make.sh
that you don't need in your project runtime.
Now you can add these two items into the excludes
parameter and the build
command ignores them,
and you won't see them in the final built directory.
You need to add the following:
{
"excludes": [
"node_modules",
"make.sh"
]
}
If you are developing a package, or you want to separate your main application into smaller packages,
you may end up having some executable files that you want to have in your main application as well.
For example, let's assume you are developing a package named rocket
add this package has an executable file named check-runner.php
.
Now if you want to see the file as an executable file in the main application,
you need to have the following configuration:
{
"executables": {
"rocket-check-runner": "check-runner.php"
}
}
Having this configuration ends up seeing a rocket-check-runner
file from the main application
linked to the check-runner.php
file inside the package directory.
The required code for autoloading used classes gets added automatically to your executables files.
This config sets the default directory for adding/removing packages to your application, as well as the default package directory for building your application's package. You can simply use any directory name for this config:
{
"packages-directory": "vendor"
}
You don't have to do anything with this config. It gets used to keep track of the required packages for your application.