服务容器/提供者可能比我想象的要简单得多,但经过几个小时的阅读后,我仍然完全没有得到它.
我在其中创建了一个简单的DateFormat
类app/Library
.在内部创建别名后,\config\app.php
我可以立即在任何控制器或刀片模板中使用它.
<?php namespace App\Library;
class DateFormat {
public static function getDate($timestamp){
// processing the timestamp
}
}
Run Code Online (Sandbox Code Playgroud)
我刚刚创建了一个服务容器吗?如果是,我是否还需要创建服务提供商?哪里有绑定到图片?
我真的很感激这个问题的一些亮点.
谢谢
php service dependency-injection inversion-of-control laravel
我需要使用ajax在服务器上上传照片.我也设置了javascript的表单,但FormData对象总是空的!我尝试了各种方法来引用实际的表单,但仍然无法正常工作.
小提琴示例:https: //jsfiddle.net/cjngvg8a/
谢谢!
HTML:
<form id="profileImageForm" action="update.php" method="post" enctype="multipart/form-data">
<input type="text" value="hello" name="test" />
<input type="file" name="profile_pic" id="image_upload"/>
<input type="submit" value="Save"/>
</form>
Run Code Online (Sandbox Code Playgroud)
JS:
$('#profileImageForm').on('submit',(function(e) {
e.preventDefault();
var formData = new FormData(this);
console.log(formData);
$.ajax({
type:'POST',
url: $(this).attr('action'),
data:formData,
cache:false,
contentType: false,
processData: false,
success:function(data){
console.log("success");
console.log(data);
}
});
}));
Run Code Online (Sandbox Code Playgroud) 我设法让我的视频自动播放在我的webview.apk中,在我的手机上测试(4.1.2)它的工作原理,而在我的Android迷你电脑(4.2)上必须点击开始播放...... :(
WebChromeClient可能是原因吗?如果它与铬有一些共同点,那也不能自动播放,而股票网页浏览器播放得很好?
我用来获取自动播放工作的javascript如下:
<html>
<head>
<script>
function callback () {
document.querySelector('video').play();
}
window.addEventListener("load", callback, false);
</script>
</head>
<body>
<div id="video_post1" style="margin: -454px 0px 0px -3px;position: absolute;">
<video controls autoplay with="600" height="400">
<source src="http://www.edmondvarga.com/demo/videos/trx.mp4" type="video/mp4">
</video>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
也许我会用另一种语法来播放它(比如:文件就绪)?
Eclipse代码,仅用于演示:
package tscolari.mobile_sample;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.WebChromeClient;
import android.media.MediaPlayer;
public class InfoSpotActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) { …
Run Code Online (Sandbox Code Playgroud) 我正在尝试向不同的用户发送不同的消息。我创建了一组电子邮件地址,并在遍历它的同时,我想将 message2 发送给 user2。
在重用相同的邮件实例时,在每次迭代开始时我声明$mail -> ClearAddresses()
,但现在 user2 获取了 user1 和 user2... 等等的消息。
我错过了什么地址在迭代开始时不会被清除?
谢谢!
// settings
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'xxx'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xxx'; // SMTP username
$mail->Password = 'xxx'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;
$mail->CharSet = "UTF-8"; // TCP port to connect …
Run Code Online (Sandbox Code Playgroud) 我正在将持续集成实现到我的Laravel工作流程中,并且在基本学习过程中,我在Gitlab上遇到了一个示例项目,其中(1.)Laravel Envoys用于编写与应用程序的部署方式有关的任务,然后与(2.)使用Gitlab CI引导过程。
我有些困惑,在我看来,使用Enovy定义任务的部分(波纹管)在定义.gitlab-ci.yml
文件内的作业时很容易复制,这使Envoy的使用变得多余:
...
@setup
$repository = 'git@gitlab.example.com:<USERNAME>/laravel-sample.git';
$releases_dir = '/var/www/app/releases';
$app_dir = '/var/www/app';
$release = date('YmdHis');
$new_release_dir = $releases_dir .'/'. $release;
@endsetup
...
@task('update_symlinks')
echo "Linking storage directory"
rm -rf {{ $new_release_dir }}/storage
ln -nfs {{ $app_dir }}/storage {{ $new_release_dir }}/storage
echo 'Linking .env file'
ln -nfs {{ $app_dir }}/.env {{ $new_release_dir }}/.env
echo 'Linking current release'
ln -nfs {{ $new_release_dir }} {{ $app_dir }}/current
@endtask
...
Run Code Online (Sandbox Code Playgroud)
如果有人错误地纠正了我,或者解释了Envoy可以为Gitlab Continuous Integration工作流程带来的好处,我将不胜感激。
我正在尝试为我的网站创建一个“设置脚本”。我想创建数据库,同时添加表格和一些内容。到目前为止,这就是我的做法,但使用多个查询似乎有点混乱:
<?php
$servername = "localhost";
$username = "root";
$password = "password";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Create database
$sql = "CREATE DATABASE MYDB";
if ($conn->query($sql) === TRUE) {
echo "1. Database created successfully <br/>";
$conn->select_db("MYDB");
$sql_members = "CREATE TABLE MEMBERS (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
USERNAME VARCHAR(30) NOT NULL,
EMAIL VARCHAR(40) NOT NULL,
DISCOUNT VARCHAR(5),
PASSW CHAR(128),
ROLE VARCHAR(9)
)";
if …
Run Code Online (Sandbox Code Playgroud) 试图建立我的聚合物2.0项目,但每次我尝试无论预设(es5捆绑,es6捆绑)或单独的标志,我得到以下警告我有一个mixin:
EdmMac: public vedtam$ polymer build
info: Clearing build/ directory...
info: (default) Building...
const DatastoreMixin = (superClass) => class extends superClass {
~~~~~~~~~~
src/mixins/datastore-mixin.html(1,57) warning [unknown-superclass] - Unable to resolve superclass superClass
info: (default) Build complete!
Run Code Online (Sandbox Code Playgroud)
构建对象:
"builds": [{
"name": "default",
"bundle": true,
"js": {"compile": true},
"css": {"minify": true},
"html": {"minify": true},
"addServiceWorker": true
}]
Run Code Online (Sandbox Code Playgroud)
来电者:app-main.html:
class MyApp extends Polymer.GestureEventListeners(DatastoreMixin(ReduxMixin(Polymer.Element))) {
Run Code Online (Sandbox Code Playgroud)
DatastoreMixin:
<script>
DatastoreMixin = function(superClass) {
return class extends superClass {
constructor() {
super();
}
static get properties() { …
Run Code Online (Sandbox Code Playgroud) 我想为我的 ImageView 构建一个放大和缩小动画,我设置了一个侦听器并将动画 RepeatCount 设置为无限。
首先,我从放大效果开始,然后在 onAnimationRepeat 方法中创建缩小部分,其中使用布尔值我想重新启动整个效果,开始再次放大。但是在第一次没有再次调用 onAnimationRepeat 之后,反过来动画正在重复但它卡在缩小部分。
我错过了什么?
//image animation
Animation anim = new ScaleAnimation(1.0f, 1.1f, 1.0f, 1.1f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(10000);
zoomIn = true;
// Start animating the image
final ImageView splash = (ImageView) findViewById(R.id.imageView);
splash.startAnimation(anim);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
if(zoomIn) {
Log.w("", "we zoom out, and zoomIn is: " + zoomIn);
Animation anim = new ScaleAnimation(1.1f, …
Run Code Online (Sandbox Code Playgroud) 我尝试直接从我的应用程序(webview.apk)调用一个javascript函数,为了启动一个自动播放html5视频剪辑的脚本,我试图在webview loadURL之后添加它,但没有运气.
也许有人可以看看代码.我错过了什么?谢谢!
package tscolari.mobile_sample;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.WebChromeClient;
import android.media.MediaPlayer;
public class InfoSpotActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView mainWebView = (WebView) findViewById(R.id.mainWebView);
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.setWebChromeClient(new WebChromeClient());
mainWebView.setWebViewClient(new MyCustomWebViewClient());
mainWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mainWebView.loadUrl("http://server.info-spot.net");
mainWebView.loadUrl("javascript:playVideo()");
}
private class MyCustomWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
} …
Run Code Online (Sandbox Code Playgroud) javascript ×3
php ×3
laravel ×2
video ×2
webview ×2
ajax ×1
android ×1
animation ×1
autoplay ×1
chromium ×1
create-table ×1
email ×1
forms ×1
gitlab ×1
html ×1
html5 ×1
imageview ×1
jquery ×1
linux ×1
loops ×1
mixins ×1
mysql ×1
phpmailer ×1
polymer ×1
polymer-2.x ×1
polymer-cli ×1
scale ×1
service ×1
subquery ×1
zooming ×1