require

Rake tasks won't run inside of my sinatra app

帅比萌擦擦* 提交于 2019-12-12 04:18:25
问题 I have a sinatra app with a Rakefile.rake and server.rb file. In the server.rb file I have get '/' do rake :test end the app loads up but crashes when I load localhost:4567/ and says undefined method 'rake' for sinatra application. I try and require the file by using require '/home/user/project/Rakefile' and I also try Rakefile.rake but both give me an error that reads "require cannot load such file." I'm using Ubuntu. I'm not sure why sinatra can't load the rakefile, but when I run rake test

Use the required / included file as base directory in PHP

六眼飞鱼酱① 提交于 2019-12-12 03:55:13
问题 I am currently using an index.php to include another file , it structure like: root / index.php / new/ index.php And I use <?php require_once("new/index.php"); ?> the problem is , all paths in it are wrong. As all paths are based on new/index.php , when i include it, all paths changes to based on index.php. Are there any way to let the outsider visit index.php but at the same time my actual code is stored in new/ folder? Thanks 回答1: Are you talking about something like <?php echo '<img src=

using require statments with if/elseif statements [duplicate]

喜夏-厌秋 提交于 2019-12-12 03:39:29
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: PHP Question: How to fix these if/elseif statements Hello is there a way to write if/ elseif statements to display multiple php pages using require statements. I am currently collecting articles from blogs using rss and displaying the links on a web page. How can I display a certain feed depending on an array value selected from a mysql database. Sorry this is a lot, hope I explained my question well. Here is

es6 equivalent for module.exports

岁酱吖の 提交于 2019-12-12 02:34:32
问题 What's the ES6 equivalent for module.exports I want to get the value of foo from an import statement module.exports = { foo: function (a) { } } Tried: export default { foo: function (a) { } } The way first one is imported is using: var file; var filename = root + "/" + fileStats.name; file = require(path.resolve(filename)); I want to use ES6 import statement. I read somewhere that this isn't supported however would like to still know if there's a work around this. 回答1: Not sure what you're

A problem with the “require” keyword not finding the file to load

半世苍凉 提交于 2019-12-12 01:04:45
问题 I have a problem with the "require" keyword in ruby, I just downloaded a gem using: gem install thegem And when I tried running an example I received the following error: <internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- ./thegem/some/path (LoadError) In the code where the problem is: needs_to_load = a_class require "gem/some/path/#{needs_to_load}" I'm a Ruby noob learning my way around and am not sure what this is, a google search didn't help but revealed that

Angular2 SystemJs Bundles and Non Bundled js

雨燕双飞 提交于 2019-12-11 21:15:46
问题 I'm new to SystemJs and Angular2. I am using 3rd party packages, some of which have bundles/code.js files and some do not. The ones that are using bundles/code.js I have managed to get working. I include <script src=foo/bundles/code.js> and am then able to import * from 'code/foo' inside my ts files. This all makes sense to me as the bundles/code.js has something like System.registerDynamic("code/foo",...) and so the import knows what code/foo is (This is my understanding of it) I have come

How to properly use PHP require [duplicate]

谁说我不能喝 提交于 2019-12-11 17:21:27
问题 This question already has answers here : Difference between require, include, require_once and include_once? (24 answers) Reference: What is variable scope, which variables are accessible from where and what are “undefined variable” errors? (3 answers) Closed 2 years ago . I have 3 files: index.php , db.php (database), and functions.php here is an example what is in each file: database.php: define ("DB_HOST", "localhost"); define ("DB_USER", "root"); define ("DB_PASS", "1234"); define ("DB

Including files from folder with foreach loop

无人久伴 提交于 2019-12-11 16:26:39
问题 I use following simple code to include all files from common folder. $path=array(); $ds=DIRECTORY_SEPARATOR; $path['root']=$_SERVER['DOCUMENT_ROOT']; $path['common']=$path['root'].$ds."common".$ds; //Include settings require $path['common'].$ds."settings.php"; //including common php files foreach (glob($path['common'].$ds."*.php") as $filename) { if($filename!="settings.php") require $path['common'].$ds.$filename; } As you see, at first I use require $path['common'].$ds."settings.php"; then

How to send additional javascript code to client from nodejs server after page load

守給你的承諾、 提交于 2019-12-11 14:57:55
问题 When a popup shows up on my website, I want the div in that popup rendered one of many different ways depending on what a certain chosen setting is. Ideally, I'd want a button pressed to open the popup, have the client ask the server for the code it needs based on what the current setting is, then once it gets the code from the server execute it and render the contents of the popup. Do I require the code on the server, save the functions as properties on an object, and send the object to the

PhpStorm 9.0 IDE doesn't recognize package classes

让人想犯罪 __ 提交于 2019-12-11 13:45:05
问题 \Braintree_Configuration::environment('sandbox'); This is showing up as "Undefined class Braintree Configuration" And inside of the package Braintree it doesn't recognize methods even though they are there in the same class. 回答1: I originally saw your question when looking to fix a problem with composer/phpstorm/braintree not knowing where the Braintree classes were. If you had given a little more context to your question like I did to mine over here then it would of been a little clear to