mustafa v1.0.1

Mustafa is Simple and Fast MVC Framework for Crystal

MustafaVC

Mustafa is MVC Framework for Crystal

Please contribute project. MustafaVC Fork

TODO

Getting Started 😎

Download Visual Studio Code and add Crystal extension for faster coding with snippets.

Add your shard.yml and install lib. Yes it's ready! Build your MVC project.

For more information, you can see Mustafa Wiki

Installation ⭐️

Add this to your application's shards.yml

dependencies:
  mustafa:
    github: guvencenanguvenal/mustafa
    branch: master

Route 🚀

http://localhost/welcome

call controller which name is Welcome

http://localhost/welcome/hello

call controller which name is Welcome and run action(method) which name is "hello"

http://localhost/welcome/hello/param1/param2

call controller which name is Welcome and run action(method) which name is "hello" and..

Input.params[0] => "param1"
Input.params[1] => "param2"

Note: params is not get or post

Configuration or Use Template 🔎

Configuration file is config.cr on src/mustafa/config/config.cr

DEFAULT_CONTROLLER = "your default controller" #this controller is default which response http://localhost/ 
MODULE_NAME = "your module name"
VIEW_PATH = "src/your module name/view" # ./src/mustafa/view/ecr_file.ecr

and choose your localhost

LOCALHOST_ADDRESS = "0.0.0.0"

or

You can use Mustafa Template to faster start.

Super Simple 🏁

Model

Model name must be capitalized case (first letter is upper, other letters is lower)

Welcomemodel.cr

class Welcomemodel < Core::Model
  init Welcomemodel, Core::Model::Scope::Singleton

  def hello
    puts "hello"
  end
end

Controller

Controller name must be capitalized case (first letter is upper, other letters is lower)

Welcomecontroller.cr

class Welcomecontroller < Core::Controller
  init Welcomecontroller

  action "index" do
  
    Core.loader.library(Customlib) do |library|
      library.as(Customlib).foo
    end
  
    Core.loader.model(Welcomemodel) do |model|
      model.as(Welcomemodel).hello
    end
  
    Core.loader.view(self, Welcomeview)
  end
end

View

View has a class and an ECR File

Welcomeview.cr

class Welcomeview < Core::View
  init "Welcome.ecr"
  
  def load
    if (view_params["key"] == "value")
      puts "hello"                      #put hello on terminal
    end
  end
end

Welcome.ecr

Selam, <%= @view_params["key"] %>!      # value

Run, go go go

Yourproject.cr

require "mustafa"
#And require your controller, view and model files

module Yourproject
  Mustafa.run
end

What's new with the new version

  • Create your custom library
  • Select your model scope
  • New loader system
  • It's now faster than before

TODO

[ ] Library improve
[ ] Database Library improve
[ ] Oracle Driver implement
[ ] add UserControl

Contribute

Please fork project MustafaVC

Thanks

Thanks porras/session for session and encoder class.

Thanks logomakr.com for logo.

Repository

mustafa

Owner
Statistic
  • 32
  • 1
  • 0
  • 0
  • 2
  • almost 7 years ago
  • January 7, 2017
License

MIT License

Links
Synced at

Fri, 29 Mar 2024 03:53:31 GMT

Languages