autoload

Composer Autoloading classes not found

最后都变了- 提交于 2019-12-03 17:11:04
问题 I have folder structure like: includes/ libraries/ Classes/ Contact/ Contact.php ContactController.php admin/ controllers/ contact/ edit.php Contact.php is my class that file that I'm trying to use. The file contains. <?php namespace Classes; class Contact { function __construct() { die('here'); } } I have my composer.json file like: { "autoload": { "psr-4": { "Classes\\": "includes/libraries/Classes/" } }, } The file I'm trying to use the Contact class in is edit.php within the admin

sqlalchemy autoloaded orm persistence

怎甘沉沦 提交于 2019-12-03 14:58:47
We are using sqlalchemy's autoload feature to do column mapping to prevent hardcoding in our code. class users(Base): __tablename__ = 'users' __table_args__ = { 'autoload': True, 'mysql_engine': 'InnoDB', 'mysql_charset': 'utf8' } Is there a way to serialize or cache autoloaded metadata/orms so we don't have to go through the autoload process every time we need to reference our orm classes from other scripts/functions? I have looked at beaker caching and pickle but haven't found a clear answer if it is possible or how to do it. Ideally we run the autload mapping script only when we have

Laravel 4: loading an old library: how?

≡放荡痞女 提交于 2019-12-03 14:18:58
I have an old library ( phpquery ) that I'd like to include in my project. I've put it inside vendor, but it doesn't work, as it's not PSR-0 compliant. I don't want it to load for every request, so I didn't put the require inside bootstrap autoload.php. I don't even know, how I can get the root of the app. Running path() gives me a URL, not what I'm after. So how can I do that? You can create a libraries directory just like in laravel 3 and include it in your class loader. You can do this via composer or laravel. //composer.json "autoload": { "classmap": [ "app/commands", "app/libraries", "app

How to autoload extended classes?

送分小仙女□ 提交于 2019-12-03 13:59:02
问题 I am planning to use PHP's autoload function to dynamicly load only class files that are needed. Now this could create a huge mess if every single function has a seperate file, So I am hoping and asking is there a way to have related classes remain in 1 class file and still be auto-loaded function __autoload($class_name){ include('classes/' . $class_name . '.class.php'); } Let's say there is a class name animals and then another class named dogs. Dogs class extends animals class, now if I

Recursively including all model subdirectories

柔情痞子 提交于 2019-12-03 12:08:02
问题 How do you load all directories recursively in the models and lib directories? In application.rb, I have the lines: config.autoload_paths += Dir[Rails.root.join('app', 'models', '{**}')] config.autoload_paths += Dir[Rails.root.join('lib', '{**}')] but they only seem to add one level of model and lib subdirectories. Thanks 回答1: this should be helpful Dir["#{config.root}/app/models/**/","#{config.root}/lib/**/"] enjoy! (: Update: Excellent question, posting example above i have simply referred

How to use a PHP library with namespacing without Composer as dependency (PSR-0)?

荒凉一梦 提交于 2019-12-03 11:55:24
问题 I need to use some PHP libraries with dependencies but I have some restrictions on the webserver of the client. It is a managed webserver and I can not use a console eg over SSH. So how do I use now these libraries without Composer? Can I create some directories manually and what directories or paths do I need to create? Also, what do I need to create so autoloading and namespacing is working? Can I create the autoload.php somehow manually and what is the content of the file? 回答1: It is

Maintaining Emacs autoload files for user-installed elisp?

孤街浪徒 提交于 2019-12-03 09:40:43
问题 Emacs has this seemingly very nice facility for building autoload files based on magic source code comments ("autoload cookies") of the form ;;;###autoload , which are to be placed on lines by themselves immediately above each definition to be autoloaded; see (elisp)Autoload. This would seem to be an ideal tool for maintaining autoloads for those little one-file packages that Emacs users inevitably end up installing in their profiles. There's just one small problem: this facility (in GNU

Codeigniter + Composer

帅比萌擦擦* 提交于 2019-12-03 09:40:32
问题 I would like to start learning Codeigniter . But it seems that Codeigniter has not support for installation via Composer. When I search in Google I found this link. It seems that Codeigniter has not support for autoload.php file created by Composer. The documentation describes the only installation via downloading .zip archive. I am not sure if Codeigniter is a good choice now. Is it? 回答1: It has composer support in version 3. According to the documentation you can set in application/config

Why doesn't Rails autoload classes from app/services?

会有一股神秘感。 提交于 2019-12-03 09:18:02
I'm working on a Rails 4.2 app and have just added app/services/fetch_artists.rb to the structure. Inside this file, I have defined a class FetchArtists; end . When trying to run rails r 'FetchArtists' it gives me a NameError: uninitialized constant FetchArtists . I've tried looking at ActiveSupport::Dependencies.autoload_paths and indeed, app/services is not there: /.../app/assets /.../app/controllers /.../app/helpers /.../app/jobs /.../app/mailers /.../app/models /.../app/controllers/concerns /.../app/models/concerns /.../spec/mailers/previews My question is, why isn't this folder

Laravel: Controller does not exist

强颜欢笑 提交于 2019-12-03 08:30:59
I added new controller in /app/controllers/admin/ folder and added the route in /app/routes.php file as well. Then i run the following command to autoload them php artisan dump-autoload I got the following error Mcrypt PHP extension required. I followed instruction given at https://askubuntu.com/questions/460837/mcrypt-extension-is-missing-in-14-04-server-for-mysql and able to resolve the mcrypt issue. After that i run the php artisan dump-autoload command but still getting following error {"error":{"type":"ReflectionException","message":"Class CoursesController does not exist","file":"\/var\