I'm designing a simple web-app in CI. I have a registration controller, and a paypal controller. Both work fine separately, but I need to use some functions of the paypal controller as a part of registration. How can I borrow those functions w/o pasting new functions into the registration controller?
It really wouldn't be a problem to paste in the paypal controller to the reg_controller, but I'd like to separate these functions if possible! :)
BTW, I'm new to CI/MVC so if there's a better way to do things, let me know!
I think you need to move your PayPal controller into a library or model. I'm not sure exactly how you're using the PayPal controller to do PayPal functions, unless you're doing a lot of redirects.
I use this class that I made in CI to do PayPal transactions (was recently updated too):
On Google Code: http://code.google.com/p/phppaypal/
On GitHub: http://github.com/drewjoh/phpPayPal
You can tweak it just a little to make it a CI library. I have working code if that helps too. You can see example code (not CI example code) to see how simple it is here: http://drewjoh.com/wiki/code/classes/phppaypal
Jamie Rumbelow made a decent PayPal library for CodeIgniter.
http://github.com/jamierumbelow/codeigniter-paypal
Related
I am trying to develop a Quote Extention for Spree, allowing customers to upload files to AWS S3.
I would like to "secure" via authentication some of its actions and Spree provides useful helpers to that end, however I couldn't manage to get it to work.
As far as I understood the matter, I have to add this line in the QuotesController.
include Spree::Core::ControllerHelpers::Auth
in my controller, as shown in this gist
Unfortunately, I still get the undefined method error authenticate_user!
For the sake of keeping this thread DRY, you can find more on my question on Spree's repository issue #5794
Any contribution is very welcome.
Thank you.
So I could delete the question since it was based upon wrong assumptions, but I rather detail how I managed to solve the authentication of the QuotesController.
Many thanks to #Hates_ and all the people in the Spree IRC for their answers!
The first wrong assumption was in regard to the design of the QuotesController which should be split up in 2 parts one for the customers, one for the shop admin backend. The second wrong assumption was that the include Spree::Core::ControllerHelpers::Auth was not going to give me the protection I wanted. So here is what I ended up with:
The Admin Side
In Spree, in order to have your controller enjoy the "protection" of the admin of the shop, this controller has to inherit like that Spree::Admin::QuotesController < Spree::Admin::BaseController. This controller would live in app/controllers/spree/admin/quotes_controller.rb. This is all you need to "protect" it. Also, it will make your views integrate into the shop's backend nicely.
The Customer Side
It is better, by design, to make another QuotesController using a different namespace app/controllers/spree/quotes_controller.rb and inheriting like that:
Spree::QuotesController < Spree:Core::BaseController
In the last 3 months, i have learnt html, css, js and php and now i'm trying to learn Framework Codeigniter. My teacher gave me a rough idea abt MVC and asked me to download a project made on codeigniter from internet and edit it.
I downloaded a login form project and tried to read it. But i'm still kind of confused how everything works. i hv 2 questions:
What is the correct approach to learn codeigniter?
In how many days one can learn codeigniter? (i practice around 6-7 hrs a day)
The best way to learn codeigniter is to read the manual of codeigniter
Because, codeigniter framework is so much popular for their well formatted and clean documentation.
Or you can check this for beginner level tutorial
Or if you want to learn codeigniter by doing practical projects then you can follow this link
I learned CI over a weekend using this technique.
Start with simply setting up a 2 page site.
Home and About Us.
Pass simple string variables from the controllers to the views.
Next, bring a model into it.
Make a method in your model that returns some plain text, to the controller and finally to the model.
Next, make the model actually make a request to your database and return the result to the constructor then view.
After that try these:
write a helper function
Try making a basic route
Log a debugging message
upload a file from a form using the upload library
That's a good grounding in CI
Keep in mind Codeigniter is no longer in development also.
If your keen on sticking with PHP, you might want to check out the similar active project called "Laravel" after getting the hang of CIs very simple MVC structure.
Good luck!
the common way is read their manual and follow the guide, the another approach is search youtube for codeigniter turial, there are many good tutorial out there and easy to follow for example here is my result in the first place for keyword "codeigniter tutorial"
https://www.youtube.com/watch?v=BP9NRZXOvIw&list=PLIQyGVrcLTeXsq37O7IBGaUwu6xEwqBWV&index=1
I'm setting up some transactional email fun in our Codeigniter app via integrating with Sendgrid.
I've got things setup and ready to move forward with creating all of the specific transactions/emails, but I was wondering about the most efficient and/or elegant way of doing so.
It seems a bit convoluted to include the appropriate email code in each of the functions. To call a specific function from a clean and separated email controller would require me to use AJAX (so as to not cause a redirect).
Is there some way that I'm not considering currently that would help balance things, namely cleanliness and separation along with coherency and ease?
Thanks for any thoughts-
Not sure about the specifics of your application structure. But you could always create a model function and call that from the functions in your controller.
CodeIgniter also comes with some built in functionality to help you send emails, specifically setting some of your email settings in a config file so you don't have to rewrite that. http://ellislab.com/codeigniter/user-guide/libraries/email.html
I actually wrote a blog post about this not too terribly long ago. Have a look at this:
http://blog.sendgrid.com/using-sendgrid-with-php-codeigniter/
Essentially, codeigniter comes with an awesome email library that makes it easy to send stuff over SMTP, so I just show you how to hook into that.
I am trying to learn backbone.js to make a web application.This is my first time with a javascript framework and I am fairly confused with some of the stuff.
I have been developing in codeigniter for a while so I do have a understanding of the MVC architecture.
My question is how do I get the data from the backbone.js front end to my codeigniter controller and save it in the database. for example to implement a simple login/register functionality with CI and backbone, how should I proceed. If anyone can guide me step step then that would be great or point me to the right resource. Thank you.
PS: I know that I have to implement a REST api with my codeigniter but I don't know how? so if someone can provide a basic controller example it'd be really helpful.
Here's a tutorial to use the API mentioned in the above reply (by the author of the library himself)
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/
I'm looking for some guidance from those that may have integrated Authorize.net into a CI application (or any PHP MVC for that matter), and/or if there are other payment processing offerings you would suggest.
In particular, does anyone have examples/can point me in the right direction of implementing Authorize.net's DPM within an MVC PHP application? My relay_response_url is set to a controller within my application, which is to then redirect it to a view for displaying the relevant success/error message(s). But when I point DPM towards my controller, it errors out as I assume its expecting to immmediately put out a response, rather than being funneled thru?
Is DPM the solution to use? Regardless, how should I capture the response from Auth.net in my controller and then pass it along to my view(s)?
Thanks!
I would check out this payment library, as it will most likely simplify your life greatly...
http://getsparks.org/packages/codeigniter-payments/versions/HEAD/show