Creating and Implementing Interfaces Codeigniter - interface

I am using codeigniter 3. I was wondering if there is a way to create and implement interfaces in codeigniter?

If you're asking if you can make the CodeIgniter framework follow your Interfaces, you could, but it would require a whole lot of refactoring in their framework, and probably wouldn't be worth the work.
If you're asking if you can add Interfaces for your custom classes while using CodeIgniter, of course you can.
interface modular{
...
}

Related

How to use a RESTful API as ORM in CakePHP 3?

In CakePHP 1.x/2.x, it was fairly simple to have a model's data come from a REST API (as opposed to a relational database), by defining a custom datasource. (Neil Crookes' CakePHP-ReST-DataSource-Plugin was a great place to start.) Slap your custom datasource on your model, and you're making calls like $this->MyModel->find() just like you were querying a MySQL table called my_models.
I'm trying to figure out how to achieve this same effect under CakePHP 3.0. That is, make find()/save()/set()/get() calls against a Table/Entity driven by a REST API.
Since 3.0's ORM system is A) fairly new, and B) a rather large departure from the old way of doing things, I haven't found any information about how to do something like this. In fact, based on this SlideShare from
José Lorenzo Rodríguez, it sounds like it might not be possible.
This means:
not going to connect to stuff that is not a relational database.
Is there someone more familiar with CakePHP 3.0 that could clarify if what I'm looking for is possible under the new ORM system? If so, could you explain what classes you'd have to extend or implement to achieve such a function?
If you want to create a complete adapter for your Rest datasource using the interfaces and classes provided by CakePHP, take a look at this early experiment fro the CakePHP team on making a datasource for Elastic Search.
Elastic Search uses a Rest API and this plugin attempts to create classes that work similar to the CakePHP ORM:
https://github.com/cakephp/elastic-search
What it implements is basically the following:
A Type class that implements the RepositoryInterface
A Document class that implements the EntityInterface
A Query class that can be used as a collection object and has similar methods
In the near future it will provide a paginator adaptor and a form helper adaptor.
If you want to save yourself this trouble, because there for you there is little value in exposing your datasource as something ORM-like, you can just use guzzle or any similar library to interface with your API and use it as a service instead of a full-blown layer.
In the year since I asked this question, UseMuffin has built a Webservice plugin that purports to "bring [...] the power of the CakePHP ORM to your favourite webservices." This sounds like exactly what I wanted at the time.

Can Zend be used with PHP ADOdb?

I have to select a framework (or role my own) and one of the databases I have to connect to is FoxPro. I found a driver here at http://adodb.sourceforge.net/ and I am guessing it's okay to use, but I don't know if I can use it in Zend. I thought Zend came with an ORM too so I didn't now if I could use it with that. Thanks.
EDIT: A better question may be can zend_db be used with adodb? can I use both of these at the same time in my zend implementation? zend_db and pdo do no have a foxpro adapter.
Zend does include Zend_Db_Adapter which provides a loose abstraction around basic database operations.
It also provides Zend_Db_Table (and other associated classes) which implement the Table Data Gateway pattern.
But you don't have to use any of Zend's database functionality if you don't want to. So the answer to your question is definitely yes. You can use ADODb in a Zend application -- or any other approach to database access that you may prefer. Just build your model objects using your db abstraction of choice, and then use them like normal from within your Zend action controllers.

Where to set the ModelMetadataprovider with DI when using MVC Turbine?

To use your own ModelMetadataProvider you normally set it in the global.asax.
I'm using MVC Turbine and I need to inject a dependency into my ModelMetadataProvider as well.
Something like this:
ModelMetadataProviders.Current = new MyModelMetadataProvider(ISomeDependency);
How is this best accomplished with MVC Turbine?
The best place to put these pieces is to override the Startup method within your web application (the type that inherits from TurbineApplication). We're currently working on making these MVC2 features easier in v2.2 by introducing a ModelMetadataBlade that will do all the wiring up for you to the ModelMetadataProvider.Current property.
So all you'll have to do is register MyModelMetadataProvider with the container like so
container.Register<ModelMetadataProvider, MyModelMetadataProvider>()
then MVC Turbine will do the rest for you. To get an idea of what I'm talking about, checkout the way we're wiring up ModelValidatorProviders. The ModelValidatorBlade asks the ServiceLocator for all the registered ModelValidatorProvider and wires them up with the runtime.
If you have any feedback or ideas, could you post them to the Google Group? Trying to keep these things organized :)
Thanks!

Simplest model code

I am very experienced with the CakePHP framework but am checking out the Zend Framework for an application that will receive massive traffic.
I'm going through the quickstart tutorial in the documentation and got to the "Create a Model and Database Table" page.
Must I or should I create all those model classes it mentions, i.e.
application/models/DbTable/Guestbook.php
application/models/GuestbookMapper.php
application/models/Guestbook.php
Coming from CakePHP it seems like quite a lot of code for some functionality I would of thought of as quite basic and generic.
Or can I just create application/models/Guestbook.php and have it extend Zend_Db_Table_Abstract?
Any help would be much appreciated.
You can create your model after the DbTable class, however one of the benefits of doing a dataMapper class between your model and your DbTable class is that you can abstract more the data engine and create strong business rules.
Zend Framework does not actually impose any restrictions or requirements on your Model classes and you are free to create them however you would like.
Depending on the requirements and scope of the project I generally still go with subclassing Zend_Db_Table_Abstract (often with my own custom extension of it as well). When it comes to a large or complicated project I have found that using a dataMapper pattern has been very helpful.
At the same time I have had some models that do not extend any class at all. They simply are there to provide some logic and do not relate to a database.

Web Framework that handles forms intuitively?

Will be starting a web app that will have to provide many different HTML forms for data entry, so I was wondering if there is a web framework out there that does this in a clever way. generally when you have forms you have many considerations like navigation, validation, etc. that are not handled very efficiently by he frameworks I've seen so far.
Has someone taken the pain out of forms?
Have you tried looking at Grails? It can take your domain classes and dynamically scaffold them into web forms and apply server-side validation. The default scaffolding provides navigation, pagination, validation, and all kinds of other -ations that are pretty good!
Here's a good tutorial.
Try Qcodo.com, It is written in PHP (but fully OOP). It manages both database layer with nice Form templating system.
I think forms are handled pretty cleverly in Ruby on Rails. And also in .Net. The latter goes pretty far in letting you reuse the database logic for validating data and also has "automatic" handling of security issues like XSS and XSRF.