requests
but you can’t use specific Django Rest Framework.PROVIDERS
list defined in your providers.py
configuration file. When a package provider is added to this list, this will allow additional bindings, commands, views, routes, migrations and assets to be registered in your project.Use this template
to create your own GitHub repository scaffolded with the default package layout and then clone your repository to start developing locally.cookiecutter
package to scaffold your package with configuration options (name, author, url...). The advantages is that you won't need to edit all the occurences of your package name after generation.cookiecutter
globally (or locally) on your computer:flake8
and pytest
and it will also install your package locally so that you can start using and testing it in the test project directly.tests/integrations
. This project is really useful to directly test your package behaviour. It is scaffolded as a default Masonite project with your package already installed (see Installing a Package section). You can run the project with the usual command:http://localhost:8000
to see the welcome page.migrate
command:API tokens
section. Click on Add API token
, give a significant name such as publish-token
and create the token. Write down the token key somewhere for later..pypirc
file in your home directory. If you do not have one then you can easily creating one using:password
key with the token you created later prefixed by pypi-
. With a token starting with AgEIcHlwaS5vcmcCJGNjYjA4M...
the .pypirc
file would look like:setup.py
file are up to date. It's the file describing your package. Fill in the correct version number you want to publish. When ready you can run:twine
if not installed yet, build the package, upload it to PyPi and delete the build artifacts. You should then see a success message and be able to browse your package on PyPi.Framework :: Masonite
classifier in setup.py
:PackageProvider
class:configure()
method is called in usual register()
method and is used to register all resources used in your package.root(import_path)
method should be called first and is used to specify the import path of your package. If your package needs to be used like this:super_awesome_package
is the import path of your package. If your package is imported like this:masonite.inertia
is the import path of your package.name(string)
method should be called in second and is used to specify the name of your package (not the PyPi package name neither the Python module name) but the name that will be used to reference your package in the publish command or in the resources paths (it should be a name without special characters and spaces i.e. a Python valid name). This will also be the name of your package configuration file.config()
Masonite helper. For this you will need to call config(path, publish=False)
inside configure()
method:super_awesome_package/config/super_awesome.py
into Masonite config. The configuration will then be available with config("super_awesome.key")
.publish=True
argument.config/super_awesome.py
.databases/migrations/
. Migrations file are published with a timestamp, so here it would result in those two files: {timestamp}_create_some_table.py
and {timestamp}_create_other_table.py
.controllers(*locations)
and then routes(*routes)
inside configure()
method.super_awesome_package/routes/api.py
and super_awesome_package/routes/web.py
and the controllers files available in super_awesome_package/controllers
you can do:views(*folders, publish=False)
inside configure()
method. The views will be namespaced after your package name:admin
folder located at super_awesome_package/admin/
containing a index.html
view you can do:publish=True
argument. The package publish command will publish the views files into the defined project views folder. With the default project settings it would be in templates/vendor/super_awesome/admin/index.html
.assets(*paths)
inside configure()
method.assets
folder located at super_awesome_package/assets/
containing some asset files and folders you can do:resources/vendor/super_awesome/
.python craft my_package_command
. For this you will need to call commands(*command_class)
inside configure()
method.python craft
you should see the two registered commands.PackageProvider
class to create your package service provider, you will be able to publish all package resources defined below in a project. You just need to run the command package:publish
with the name of the package (declared inside configure()
method). With our example it would be:--resources
flag: