How do I 'programaticaly' create a new content type with hook_install in D7? I am trying to create a .INSTALL file which creates a content type (Apples) for my module (Fruit). I have dropped the following file (fruit.install) into my module folder with the .INFO file and .MODULE file. After enabling the Fruit module, I look into the database and find that there is no new entry in the node_type table. I must be missing a vital step? or I have made an obvious mistake, I think?

&lt;?php

/**
 * Implements hook_install()
 */

function fruit_install() {

    // * If the content type does not exist then create it.
    if (!in_array('Apples', node_type_get_names())) {
        $type = array(
            'type' =&gt; 'apples',
            'name' =&gt; 'Apples',
            'base' =&gt; 'node_content',
            'custom' =&gt; 1,
            'modified' =&gt; 1,
            'locked' =&gt; 0,
        );
        $type = node_type_set_defaults($type);
        node_type_save($type);
        // * Set 'Apples' options
        variable_set('node_preview_apples', 0);     // Set 'Preview before submitting' to 'Disabled'
    }
}
The reason I was not seeing my 'Apples' content type appear in the node_type table was because I did not realise that I had to uninstall my module then reinstall it every time I wanted to test my code changes. I was just disabling the 'Fruit' module and expecting my .INSTALL file to do its work when I re-enabled the module again. You have to disable and uninstall (not just disable) then re-enable. Apparently you can manually remove the module from the system table also, but I did not go there.

The code I pasted in above does work - although it may not be the 'correct' way of creating a content type. I'm not sure. My method mirrors how I would acheive the same with the Field UI: Add a new content type, set the content type options, add any new fields, then create the required instances of those new fields. This seems logical to me, but you may find the other solutions suggested here to be better.