I have a project and I'm only responsible for the Back-End development.
In the Back-End I have to create an API that generally have CRUD operations, and the problem is that they are a lot, so to explain exactly here is an example:
Demand => Create a CRUD for Article(Id:number, Title:string, Thumbnail:picture, Content:text, Tags:text)
Explanation => I have to create everything needed so the Front-end can send requests to Create, Read, List, Update or Delete an Article (Return data as JSON)
Problem => I'm searching for a package or a tool that generates that automatically, knowing that a request could contain files or pictures not only text data.
Please Don't Forget
I'm not seeking for a view generator [I'm not working for the Front-End] I'm only responsible for the Back-End
Everything I need do exist in other frameworks, but I want to work with Laravel
I wish you give me tools or packages that you have used not from Google searches because I'm searching for the 4th day
I found this http://labs.infyom.com/laravelgenerator/ but it seems that it have a little bit complicated documentation (Maybe the problem in me)
I'm using Laravel 5
There are several great options for automatic generation of api in laravel you can checkout Dreamfactory, infyom or apiato, I recommend infyom if you have a small project and you need simple api.
It's not totally clear to me what you're looking for. Regarding routes and controllers, Laravel's built-in functionality for Resource Controllers is quite useful in providing general REST scaffolding. If you're interested in all the details of implementing CRUD-like functionality, that's a more involved topic and I'd advise spending some time reading through Laravel's fairly comprehensive documentation.
Try Laravel API/Scaffold/CRUD Generator
Related
I'm currently learning laravel for a small community based website project. I have the necessity to include some custom code/classes in the laravel code. I'll write some custom code that will call some remote api and the JSON response will be converted into some laravel' models and inserted into the database. I would know the right approach to do this in the "laravel 5.5 way" and what components of the framework I should use. Thanks!
It's awesome you are learning Laravel, you will find that you will be able to do so much with it.
You could achieve that by good old php in a controller (in app/Http/Controllers/) and save it from there in the database
A good place to start is laracasts.com as the instructor Jeffery Way takes you from zero to hero in no time.
https://laracasts.com/series/laravel-from-scratch-2017
Have fun.
First of all, Everything is kind of confusing. There is a few tutorials and complete documentation but i feel like something is just not working way it should. For now I'm a little bit confused and discouraged. I learned how to write forms, how to make views with blade. How to menage migrations and even seeds. I know how to create new controller and simple routes.
But guys... I need some advice if you would answer...
I created a form with a view for example that form:
{{Form::open(array('url' => 'person/confirm'))}}
{{Form::label('firstname', 'Firstname:')}}
{{Form::text('firstname')}}
{{Form::label('lastname', 'Lastname:')}}
{{Form::text('lastname')}}
{{Form::label('company_name', 'Company name:')}}
{{Form::text('company_name')}}
{{Form::label('mail', 'Mail:')}}
{{Form::text('mail')}}
{{Form::label('phone', 'Phone:')}}
{{Form::text('phone')}}
{{Form::label('additional_phone', 'Additional phone:')}}
{{Form::text('additional_phone')}}
{{Form::label('city', 'City:')}}
{{Form::text('city')}}
{{Form::label('postalcode', 'Postalcode:')}}
{{Form::text('postalcode')}}
{{Form::label('address', 'Address:')}}
{{Form::text('address')}}
{{Form::label('notes', 'Notes:')}}
{{Form::text('notes')}}
{{Form::submit('Submit')}}
{{Form::close()}}
Nothing fancy, just a basic form. If I call submit, it will take me to person/confirm route. And it will be like this:
Route::post('person/confirm', function(){
$input = Input::all();
DB::table('humanity')->insert(
array('firstname' => $firstname);
);
}
I know that it is wrong.
How to get values from $input?
How to insert it to table correctly and safely?
Where is the best place to make query call?
It will be better to make query before routing starts or when next route will execute?
It would be good to create query in controller function and execute it in route then redirect to "message: Success"?
What exactly are classes and models and how can I use them?
I plan to write some system and day by day it makes me more sicker than satisfied. Something call me that I had hitched my wagon to a star.
Thank you in advice.
It looks like you're in way over your head, especially since you asked what classes are.
I'd suggest putting Laravel (or any framework, for that matter) aside for a while until you have a solid understanding about object oriented programming and architectural patterns such as MVC / MVP. While Laravel resources will improve your knowledge quite a bit, it won't be nearly enough to create well structured applications.
Here are a couple of books that might be useful:
PHP Objects, Patterns and Practice
Clean Code: A Handbook of Agile Software Craftsmanship
Ok so first off I suggest you look into Eloquent. Laravels ORM (http://laravel.com/docs/eloquent).
Eloquent will allow you to do this:
$human = new Human(Input::all());
$human->save();
But we can come back to that, your first question here is how to use the Input class.
The real documentation can be found under Requests in the laravel documentation, but here's a brief guide.
Input::get('firstname'); //gets the first name
Input::get('lastname'); //get doesn't refer to the method, "get" will retrieve from post or get.
Input::all(); //will get you all input as an array - don't forget to validate
Input::except(array('csrf_token')); //will get you everything except for the 'csrf_token' as an array
One of the best ways to get help with Laravel is through the Laravel IRC channel, the community is great.
#Laravel is a place where many developers hang out and discuss the framework. Many people frequently pop their heads in looking for some
help.
But, the real-time chat nature of IRC can be a refreshing contrast to posting on a forum and waiting for a reply.
The official community hub for laravel
Laravel.io has forums along with a plethora or useful tools such as the pastebin, you should become friends.
The other resource I suggest is Taylor's book
It's not free but it's well worth it.
Written by the creator of Laravel, this is the definitive guide to
advanced application development with Laravel 4. Learn about
dependency injection, interfaces, service providers, SOLID design, and
more while exploring practical, real-world code examples. Whether
you're building a robust, large application with the Laravel
framework, or just want to sharpen your software design chops, this
book will be of great value to you and your team.
This is what I have:
An entity-relational schema, modelled for Doctrine 2.0 (in PHP);
The generated database, on a MySQL server.
This is what I want:
A very basic CRUD web-interface to the database, that allows me to (you guessed it!) create, read, update and delete records, with extra credit for implementing CRUD operations on entities and relations instead of records.
Now, I'm terrible at writing web applications myself (read: I'm lazy). Are there any options to generate a CRUD web application from a MySQL database, or from a set of Doctrine entities?
I'd be willing to stop using PHP (and thus rewrite the entities for JPA, Ruby ActiveRecord, etc...) but not MySQL.
I see a lot of similar questions: however, most of these questions have answers that give CRUD operations for in PHP code, or recommend using Doctrine.
An answer such as "There is no such tool, stop being lazy" would also be appreciated.
You should have a look at Grocery CRUD.
Really simple, easy to use /deploy and neat UI.
http://www.web-and-development.com/grocery_crud/
I did a complete web CRUD of my DB in a couple of hours (including additional PHP webservices) Amazing :-)
Symfony does this (at least the 1.x series I am used to). I should think version 2.0 also does, under either Doctrine or Propel (and both of those will work with MySQL).
CakePHP (user guide) takes a database model and generates controllers that do basic CRUD operations for all of your tables. It also includes views and a basic stylesheet.
If your hosting setup can handle Python, the web2py framework offers instant CRUD for a database and a very user friendly (and laziness-friendly) online dev environment. I don't think it's designed to be laid overtop of an existing database, but you can import a CSV file with your database contents. http://www.web2py.com
One of the great things about web2py is that creating custom (public) CRUD pages is also dead easy. In a controller file it's as easy as
form = CRUD.create(db.myTable)
return dict(form = form)
Then in a view file you just add
{{=form}}
And that's it! All of the form creation, input validation, etc., is handled for you. I should also add that the data abstraction layer in web2py is very easy to learn and meshes with mySQL easily. One great thing about it is that web2py performs on-the-fly changes to your datastructure or even migrations from one DB back-end to another.
Not every hosting company knows how to support web2py, but it's easy to deploy on the Google App Engine or with a company like Fluxflex.com
I've been looking for a drop-in admin panel like this too, so far I've 3:
AjaxCrud - http://ajaxcrud.com/
Peek from Code Canyon - http://bit.ly/toKKrB
SQLBuddy - http://www.sqlbuddy.com/
Love to hear any other suggestions!
Ruby on Rails' "Scaffolding" should be exactly what you're looking for...
As according to this answer, I've tried Xataface, which gave me as decent a result as CakePHP or Web2Py would have given me. Am now trying Symfony 2.0 (which is a lot harder then I'd have expected) for the extra credit.
My boss give me some assignment to find information "How to add a controller by using wildflower admin (dashboard)? and how can we manipulate it (wf admin)?". I've searched each with Google but it's too difficult to find it. Maybe I'm not so great to do the research job. So, please help me you guys.
Wildflower is a CMS built on the CakePHP framework. A controller is a code construct used in the CakePHP framework. If I understand your question correctly, what your boss is asking for is some way to make the application write code into itself...
However, if I understand your boss' intent correctly, it sounds like he wants something like Drupal's Content Construction Kit (CCK) in Wildflower which, as far as I know, doesn't exist.
CakePHP comes with a console app called "bake". You can quickly create "scaffolding" for a model by running some bake commands. In theory, you could write an extension for Wildflower that could send commands to bake to generate scaffolding for quick add/edit/delete interfaces for those models.... but they wouldn't integrate with the WF admin or WF in general.
With all the effort it would take to build an interface like that, you could just add the new models to the application yourself, or build a proper CCK-like extension for WF.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Is there any thing in PHP to create basic scaffold, like in Rails?
EDIT: I need something to prototype quickly..
Some frameworks like Symfony, CakePHP, Akelos, CodeIgniter and others have support for scaffolding.
However if you don't want to use a framework you can try phpScaffold which generates CRUD scaffold pages based on phpMyAdmin table exports...
I also wanted some fast prototyping, but I wanted it to generate the code, so it's easy to update it. I made many improvements on phpScaffold (HTML5, nice CSS, many models at once, etc) which are published on http://github.com/tute/phpscaffold.
Phreeze makes this simple and easy. http://phreeze.com/
QCodo is another great option. And since it uses reflection to do Code Generation instead of reflection at runtime, you'll likely see better performance.
First, Rails is a framework. PHP is a language. PHP does not have built-in scaffolding support, just as Ruby--the language Rails is build on--does not. A framework like CakePHP, however, does support scaffolding.
Second, I see that you raised an objection to CakePHP because "you still have to do a bunch of stuff." That's true--with any framework, you're going to have to learn new conventions, configurations etc.
CakePHP got plenty of scaffolding options
If you throw Crud + API plugin on top, you basically got everything you need, with tons of nice additions
cakephp-crud: The active successor of the two projects below. Provides both Crud actions, API, Scaffolding, Searches and more
Crud Plugin: https://github.com/nodesagency/Platform-Crud-Plugin
API Plugin: https://github.com/nodesagency/Platform-API-plugin
They all utilize CakePHP events, so its really simple to extend and modify the default behavior
For myslef I Use CodeIniter for development, sure they have scaffolding, but only in terms of a "simple scaffolding" which mean you're not gonna use it in live product (i dunno about everyone but i'm only using it as some tools) .
but if you need some like CRUD generator you can use SparkPlug , or Ignition both of them can be used on Codeigniter
This was asked quite some time ago, but if it's still relevant check out this nice scaffolding class (check the demo)
Yiiframework has a good code scaffolding system called Gii. It's web based. Once you create the tables, you can generate the CRUD classes from within the browser. No command line needed. I like this scaffolding.
If you use CakePHP as the web framework it supports scafalding. See this link for more info. http://book.cakephp.org/2.0/en/controllers/scaffolding.html
I'm not sure what the SO policy is for dead thread revival but I figured I would add my own two cents in case none of the above solutions were satisfactory. If you're looking for a PHP-based MySQL scaffolding tool, check out AMPLE Scaffolder. The entire package is contained within a single PHP file (less than 200k) that can simply be dropped into a web accessible directory whereupon you have immediate access to local and remote MySQL databases based on the internal database permissions. No schema exporting, configuration files, or other hassles. Plus, there's a whole lot of other capabilities to offer as well. Just thought I'd share it in case you were looking for another option. Feel free to check it out and post feedback if you have any questions.