Part of the EllisLab Network
   
1 of 5
1
CodeCrafter 0.3.0 (BETA) - CRUD Source Code generator for CodeIgniter released
Posted: 19 January 2007 07:16 AM   [ Ignore ]  
Research Assistant
RankRankRank
Total Posts:  558
Joined  06-17-2006

I’ve released V0.3 of Code Crafter, a code generator utility written especially for the CI framework.
Code Crafter is a code generator for the Code Igniter framework.

My intention was to release it once settling down table relationships for good, but I am releasing it due to some interest in new features and some bug fixes.

Some notable changes:-
- A redesign of the CodeCrafter user interface.
- the generation of a runnable application upon code generation.
- The choice of using the CI AcctiveRecord of normal CI database functions.
- The option to use short or long tags (thanks Dave Nutall
- Verbose mode model generation
- Optional XXS filtering of data
- Filed level customisation.
- Key relations
- Cleaner Code

Unfortunately I have not had time to update the user manual. I am also busy with some projects that will put me out of action for a week or two, but I’ll try and address whatever issues I can. Please be understanding.

I’m still guiding by the principals that guided the first version.. So the ability to generate an entire application 5 seconds or less after startup is still there. Additional options for those that require it.

The field relationships are not what I intended, but I felt that as longs as the CI libraries are not supporting table or field relationships, my hands are tied. I did however, provide in the the interim a workable solution get get field relationships in a workable state. I was guided by what I had. I don;t want to introduce a framework-in-a-framework.

To install:
- Head over to http://www.datacraft.co.za/codecrafter/ and grab a copy of the code.
- Expand the archive somewhere temporarily.
- Install your version of Code Igniter
- Copy the following form CodeCraf to your CI install
  - assets directory
  - application/config/application.php file
  - application/controllers/ directory
  - application/views/ directory
  - application/crud_output/ directory (It’s empty, but don’t leave it out!)
- Change the application/config/application.php file as you wish. see the comments for more information.
- Set your default routes (if you wish)
- Browse to:
  http://yourdomain/path_to_install/codecrafter/

For now, make do without the help manual. I’ll throw something together. If you look at the old manual though, it’s not vastly different that you’ll be lost.

Some other forum links

http://codeigniter.com/forums/viewthread/45762/

http://codeigniter.com/forums/viewthread/47079/

http://codeigniter.com/forums/viewthread/46481/

 Signature 

CodeCrafter - Open Source Code Generation for CI

Profile
 
 
Posted: 19 January 2007 07:47 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  137
Joined  11-05-2006

Thanks a lot, Crafter! I downloaded the new release and I’ll try it soon… I’m sure it will fulfill my expectations grin

 Signature 

When a good coder dies, he degrades gracefully…

My Website |
Follow me on Twitter

Profile
 
 
Posted: 19 January 2007 08:34 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  84
Joined  01-08-2007

Great job, I’ll be playing around with it soon. Also looking forward to the table associations. wink

Profile
 
 
Posted: 19 January 2007 09:25 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
RankRankRank
Total Posts:  558
Joined  06-17-2006
siric - 19 January 2007 08:34 AM

Great job, I’ll be playing around with it soon. Also looking forward to the table associations. wink

I haven’t done the table associations at the model level, the way most db relations libraries would do it. Instead I took the approach that the generated code will support forign key lookups.

To see that work, you must select a table, then a field and customise the field, adding a field lookup.

CodeCrafter then generates a call to the foreign table model requesting data, and passes that the view, who then display the data as a dropdown xontrol.

I realise this is severely limited, as it does noy support the BelongsTo relations. As I mentioned earlier, I don’t want to impose a framwork on the generated code. So this is a first step to supporting all relationships (inclusing a many:many) in the future.

What I’d like is for an indication as how best to proceed from here in processing the table relationship.

In the meanwhile, I’ve started an alternate ActiveRecord library that will support relationships, I’ll release that soon, and if it seems a viable solution, then perhaps this can (optionally) be integrated with the generated code.

 Signature 

CodeCrafter - Open Source Code Generation for CI

Profile
 
 
Posted: 19 January 2007 09:30 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
RankRankRank
Total Posts:  558
Joined  06-17-2006

DEPLOYING THE GENERATED CODE

To deploy the generated code.
1. Generated the code fro an enitire database with the following options:
  - enable navigation
  - write to disk
2. Copy the contents of
    [your_dir]/system.application/crud_output/[your_database] to your new code igniter installation.
3. invoke the appmain controller
  http://your_domain/appmain/

 Signature 

CodeCrafter - Open Source Code Generation for CI

Profile
 
 
Posted: 19 January 2007 11:57 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
RankRankRank
Total Posts:  558
Joined  06-17-2006

On certain installations, clicking the “connect” button gives some error.

To overcome this, in the controller codecrafter.php, set all instances (actually the “fix” is just needed for function fetchdbs() )  of

$db['db_debug'] = TRUE;

to

$db['db_debug'] = FALSE;

This seems to be happening when a database value is not provided on the form.  The code

$result = $this->load->database($db);

is executed without a database supplied, which causes the error message: Unable to select the specified database, whcih is correct, but an “intended error”.

 Signature 

CodeCrafter - Open Source Code Generation for CI

Profile
 
 
Posted: 19 January 2007 01:43 PM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  47
Joined  10-31-2006

I think line 320 of codecrafter.php should read:

$tables = $this->db->list_tables();

George

Profile
 
 
Posted: 19 January 2007 02:40 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
RankRankRank
Total Posts:  558
Joined  06-17-2006
glemigh - 19 January 2007 01:43 PM

I think line 320 of codecrafter.php should read:

$tables = $this->db->list_tables();

Yes, your’e right. In 1.4.1 it was tables() and was subsequently renamed to list_tables(). I saw no entry on the change log.

Sorry about that, I tested last on CI 1.4.1 and released the code from there.

Future versions should have something like

if (function_exists('tables')) {
            $tables
= $this->db->tables();
         
} else {
            $tables
= $this->db->list_tables();
         
}
 Signature 

CodeCrafter - Open Source Code Generation for CI

Profile
 
 
Posted: 21 February 2007 01:05 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  2
Joined  02-21-2007

I must be missing something obvious, but i keep getting, when i try to run codecrafter 0.3:
Fatal error: Call to undefined function site_url() in ...system/application/views/codecrafter_new.php on line 860

Tried all kinds of things. This ring a bell w/ anyone??

thanks,
mark

Profile
 
 
Posted: 21 February 2007 01:26 PM   [ Ignore ]   [ # 9 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  472
Joined  09-26-2006

Is the url helper loaded?

 Signature 

Old programmers never die, they just parse away.

Profile
 
 
Posted: 21 February 2007 01:55 PM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  2
Joined  02-21-2007

Rock and roll high school!!
I added it to line 68 of codecrafter.php:

Old:

...
$this->load->helper('date');
}

New

...
$this->load->helper('date');
$this->load->helper('url');
}

   

now it works!
thanks for the tip.
m

Profile
 
 
Posted: 22 February 2007 12:20 PM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  472
Joined  09-26-2006

That thing’s bitten me so many times i’m immune to rabies.

 Signature 

Old programmers never die, they just parse away.

Profile
 
 
Posted: 08 March 2007 05:02 PM   [ Ignore ]   [ # 12 ]  
Lab Assistant
RankRank
Total Posts:  228
Joined  03-06-2007

I have just tried running CodeCrafter but when I load the appmain I get the following error

Severity: Notice

Message: Undefined variable: page_contents

Filename: site/main.php

Line Number: 7

 Signature 

EE2: 2.0.1 Beta - Build: 20100121
MSM: 2.0 - Build: 20091211
nifootball.co.uk

Profile
 
 
Posted: 08 March 2007 06:34 PM   [ Ignore ]   [ # 13 ]  
Research Assistant
RankRankRank
Total Posts:  558
Joined  06-17-2006

Change the following line in the views/site/main.php file as follows:

<?= $page_contents; ?>

to

<?= (isset($page_contents))?$page_contents:'Welcome to my app'; ?>

EDIT; Added missing close bracket in the code segment. Oopsee!

 Signature 

CodeCrafter - Open Source Code Generation for CI

Profile
 
 
Posted: 09 March 2007 02:18 AM   [ Ignore ]   [ # 14 ]  
Lab Assistant
RankRank
Total Posts:  228
Joined  03-06-2007

Sorry but I get this.

Parse error: syntax error, unexpected ‘;’ in E:\Web Server\xampp\htdocs\nifootball\system\application\views\site\main.php on line 7

 Signature 

EE2: 2.0.1 Beta - Build: 20100121
MSM: 2.0 - Build: 20091211
nifootball.co.uk

Profile
 
 
Posted: 09 March 2007 03:32 AM   [ Ignore ]   [ # 15 ]  
Research Assistant
RankRankRank
Total Posts:  558
Joined  06-17-2006

Yeah. There was a missing close bracket in the above code. Cut and past the updated version.

 Signature 

CodeCrafter - Open Source Code Generation for CI

Profile
 
 
   
1 of 5
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 721, on January 06, 2010 09:38 AM
Total Registered Members: 115022 Total Logged-in Users: 74
Total Topics: 122459 Total Anonymous Users: 6
Total Replies: 647355 Total Guests: 496
Total Posts: 769814    
Members ( View Memberlist )