Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7160321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:22:48+00:00 2026-05-28T13:22:48+00:00

Where in cake to create a function that will be able to be used

  • 0

Where in cake to create a function that will be able to be used by any controller, model, view and every other place. I know that this is not very OOP but I need a function for checking the mime_type of files. ATM I em using a variable set in the bootstrap but dont think that this is the best place because I dont need this on every page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:22:49+00:00Added an answer on May 28, 2026 at 1:22 pm

    CakePHP is object-oriented, thus you would be encouraged to create a class and a method inside it, not a bare function. To create a class you can use from anywhere, put a file in APP/libs (for example my_class.php), make a class in it (like “class MyClass”), and then import it wherever you want to use it (using “App::Import(‘Lib’, ‘MyClass’);”).

    But as per your quesion, reachable from eveywhere, you could do it in any central file, such as config/bootstrap.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Profile model/controller in my cake app as well as an index.ctp
I'm trying to create a cron job that will send a weekly newsletter. I
In my cake app I have a model called faqs, controller called faqs_controller &
I'm working in a CakePHP Model class, writing a function that is supposed to
I am learning cakephp by myself. I tried to create a user controller with
I'm new to cakePHP. I'm trying to create a login page. I was able
I created an app with the cake bake command, and one table used text
I am uploading a file in cake php. <?php echo $form->create(Video,array('action'=>'add','name'=>'thisform','enctype'=>'multipart/formdata','onsubmit'=>'javascript: return validate();')); echo
I created a login view for my Employee controller , but when the login
I'm trying to upload a file with cakePHP. This is the view: echo $form->create(null,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.