If you are thinking about packaging source-code from some of your projects, you might be wondering how to go about it. In this post I’ll cover all the basics of taking source code from an existing project and preparing it for publishing on Binpress.

Prepare and normalize files and directories

The files needed for the component you want to publish might be scattered over several folders in your project. You need to locate all those files and place them in a directory structure that will be easy to integrate in other projects. Common standard directories for a framework component:

/public  -- All the publicly accessible files
    /images
    /styles
    /js
/library  -- Generic reusable server-side code
/application -- Application specific server-side code
   /models
   /controllers
   /views
/tests -- Unit tests (if applicable)
  1. The application specific directories will change depending on the framework you are using.
  2. WordPress / Joomla / Drupal and other platforms have their own standards for directory structure. Please follow the directory guidelines for the platform you are publishing for.

Minimize external dependencies

Try to remove any external dependencies that might be included in your code. This includes extending classes that you will not be including in the component – a common case using frameworks. Change the classes to extend the original framework class, and provide any necessary functionality in the component classes.

Try to make sure you are not including files that are not being used by the component just for being in the same directories as other files.

Remove copyrighted material

You need to remove and / or replace any copyrighted material included in your works. This includes your own copyrighted images and content (including logo) and any other material that might be copyrighted.

If you are not sure about the copyright status of the materials you are using, please visit the source at which you got it from. If there is no indication of copyright status, you are welcome to send us a message to legal@binpress.com to clear content for use.

Comment your source-code

If you are not in the habit of commenting your source-code or use a non-standard approach, now is the time to work on it a little. Try to use a standard commenting style – for example, the phpDOC style is considered the de-facto standard for PHP.

Familiarize yourself with the standard commenting style for your language / framework / platform, and try to comment your source-code where relevant (over commenting is not needed).

If you find you need to add many inline comments in order to explain what some code is doing, perhaps you need to refactor it a bit to make it more readable.

Add working examples

Working examples are very important for prospective clients. If you have a live site already showcasing the component’s abilities, you can link directly to that. Make sure though that regular visitors can use the functionality you offer.

If no such site is available, strongly consider preparing a demo site for your component. The demo site is your chance to show what your component can do, and is a very strong factor for prospective clients.

We will soon be releasing a style package for demo sites for a designed look and feel that is similar to Binpress. We are aware that most developers are design-challenged, and we will try to help as much as we can in this respect.

Zip it up and upload to Binpress

Now that your component is ready for publishing, what is left is to zip it up (using a free program such as 7zip) while retaining the directory structure, and upload it to Binpress.

That’s it! a bit time consuming but not too difficult. After uploading the package you need to work on the component profile (we will talk about that in a future article). If you have any questions regarding the packaging process, please leave those in the comments.

Posted in Binpress